127

I get an error when running npm install. The error is:

npm ERR! Cannot read property 'pickAlgorithm' of null

npm ERR! A complete log of this run can be found in:
npm ERR!    npm-cache\_logs\2021-10-14T08_03_47_266Z-debug.log

I did the following but the error stays:

  1. Deleted node-modules
  2. Deleted the given file
  3. Running npm cache clear --force

Environment:

OS: Windows 10
react native: 0.65.1
Node: 14.17.4
npm: 7.21.0

Kiana Kazeminejad
  • 1,691
  • 3
  • 6
  • 20

17 Answers17

245

The only thing that helped me was clearing cache:

npm cache clear --force
Zimeni
  • 2,529
  • 2
  • 8
  • 6
  • 7
    this works, but I'm having to do this repeatedly now, any one know how to keep this from happening for good?? – Kenzo Aug 27 '22 at 19:58
52

please use following:

npm cache clear --force

npm install

in my case it is working

Syscall
  • 19,327
  • 10
  • 37
  • 52
sachin sakhare
  • 529
  • 3
  • 2
22

For me, the error came up while I was trying to work with the json-server module. And clearing the cache worked for me

npm cache clear --force

Afterwards, reinstall/update your mode modules

npm install

If that doesn't work, try reseting you npm config:

npm config set registry https://registry.npmjs.org/
Farhan Sodiq
  • 221
  • 2
  • 4
15

It seems that running

npm cache clear --force

Is what worked and recommended by everyone. Unfortunately, it did not work for me. There were other suggestions to save-dev first. This also did not work for me.

What I did in order to overcome this issue myself, was narrowing my package.json dependencies. I removed all of them, and kept returning them incrementally until I found the dependency that was causing the issue. I updated the dependency version, and this was what I needed to overcome this issue.

orabis
  • 2,749
  • 2
  • 13
  • 29
12

Upgraded to npm v7.23.0 and then npm install so it's working fine now.

Kiana Kazeminejad
  • 1,691
  • 3
  • 6
  • 20
12

Running this worked for me

npm config set registry https://registry.npmjs.org/
Sivadas Rajan
  • 578
  • 5
  • 9
5

if you are using Windows OS, close VS Code then open command prompt as administrator and run npm cache verify and npm install

it works for me

Bekti Galan
  • 81
  • 2
  • 8
5

In my case we had an old package-lock.json that caused these issues. Regenerating package-lock.json fixed the issue. To do this delete package-lock.json and then run npm install

Crhistian Ramirez
  • 1,066
  • 12
  • 20
3

Solution 1: Cache Clear

First, run this command:- npm cache clear --force

Then run this command:- npm install

Solution 2: set npm config

You need to set npm config registry just like this.

npm config set registry https://registry.npmjs.org/

We can also run npm install with registry options for multiple custom registry URLs.

npm install --registry=https://registry.npmjs.org/ 
npm install --registry=https://custom.npm.registry.com/ 
2

First run npm cache clear --force and then close VPN. It worked for me (in China)

网于睿
  • 51
  • 5
1

One of the packages was deprecated. I started in new folder a test project and then copied some of the packages to this tested project until found the problematic package.

create on new folder a test-project and open cmd in this location.

npm init -y // creates package.json with defaults copy to depencencies / devdependencies in that package.json packeges from the origin project. npm i

Zohar Chiprut
  • 752
  • 1
  • 8
  • 18
1

My problem was because the wifi adaptor of my PC was very inconsistent and would give network errors often, giving the error mentioned, among others, when trying to install bigger packages (in my case, expo). What helped in my case was tethering my android phone to PC and using the connection that way.

This link helped me getting it done: https://support.google.com/pixelphone/answer/2812516

TheYuriG
  • 134
  • 1
  • 9
0

I completely deleted nodejs and then reinstalled version 16 of it.

The following links are helpful:

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
0

Use npm upgrade npm to get the latest version of npm

0

If these solutions didn't work,

npm cache clear --force
npm install

Then this will definitely work!

npm config set registry https://registry.npmjs.org/

After executing the above command,

npm install --legacy-peer-deps
-1

i was try this step to solve that problem:

  1. close VS Code
  2. Run from CMD
  3. npm cache clear --force
  4. npm cache verify
  5. npm install -g create-react-app
Kiana Kazeminejad
  • 1,691
  • 3
  • 6
  • 20
-1
  1. close VS code،

  2. Install last version Node

  3. CMD : npm install -g create-react-app

  4. npm cache clear --force

  5. npx create-react-app <projectName>

Or Reinstall node

Vishnu
  • 495
  • 8
  • 14
Soroush
  • 1
  • 3
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 28 '22 at 14:02