141

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

2
  • 6
    Why is there so many duplicate answers on this (legitimate) question? Commented Oct 26, 2022 at 3:15
  • Some times make sure you have disconnected from your VPN before doing npm install. It will also can cause the issue Commented Jul 18, 2024 at 13:50

18 Answers 18

272

The only thing that helped me was clearing cache:

npm cache clear --force
Sign up to request clarification or add additional context in comments.

1 Comment

this works, but I'm having to do this repeatedly now, any one know how to keep this from happening for good??
57

please use following:

npm cache clear --force

npm install

in my case it is working

Comments

29

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/

Comments

17

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.

Comments

16

Running this worked for me

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

Comments

13

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

Comments

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

Comments

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

Comments

4

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/ 

Comments

2

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

Comments

2

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

Comments

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

Comments

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

Comments

0

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

The following links are helpful:

Comments

0

Use npm upgrade npm to get the latest version of npm

Comments

0

1 liner shortcut

npm cache clear -f && npm i

Comments

-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

1 Comment

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.
-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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.