31

iam getting below error with npm while creating react app

npm ERR! Cannot read properties of null (reading 'pickAlgorithm')

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Nagamanickam\AppData\Local\npm-cache_logs\2021-11-18T12_01_45_525Z-debug.log

3

14 Answers 14

23

I resolved it by deleting node_modules and package-lock.json and run npm install again.

3
  • 12
    didn't solve it for me
    – dialex
    Commented Feb 9, 2022 at 15:51
  • Didn't work for me too Commented Feb 23, 2022 at 6:20
  • Problem for me was in Jenkins Builds only, local builds were successful. The cause was that we do commit package-lock.json. In the build Jenkins appends the build-no to version in package.json. This way package.json and package-lock.json were inconsistent and npm install failed. The solution was to delete package-lock.json prior to npm install. Commented Jul 10, 2023 at 12:26
19

my npm version is 8.1.4 and i solve this problem by running :

npm cache clear --force

5
  • 37
    didn't solve it for me
    – dialex
    Commented Feb 9, 2022 at 15:51
  • Didn't work for me too Commented Feb 23, 2022 at 6:19
  • Did not work for me as well Commented Jan 13, 2023 at 7:37
  • Didn't work for me either
    – ataraxia
    Commented Mar 1, 2023 at 15:01
  • 1
    Fixed it for me!
    – Ragav Y
    Commented Apr 21, 2023 at 12:08
13

solved with npm i --legacy-peer-deps on react-native version .70

8

Just run these 2 commands :

npm cache clear --force
npm install
1
  • 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.
    – Community Bot
    Commented Jul 19, 2022 at 18:31
3

Probably it's a project that works with Yarn and not NPM. Try Yarn instead of NPM.

yarn install

and then you can do

yarn start

or

npm start
0
3

Your dependency tree may be broken (due to incompartible peer dependencies) you can try running npm install with --legacy-peer-deps or --force to bypass this issue for the mean time.

3

In my case i updated npm via:

npm update -g npm

After it, everything worked fine.

Don't know why, i didn't expect it.

2

If you have this issue on the CI:

$ npm ci
npm ERR! Cannot read property '<any-package-here>' of undefined

You should check the version of Nodeon the CI. It was outdated for me.

1
  • This saved my time. I found that I used the version of Node which isn't matched with the requirement in the package.json.
    – Phin
    Commented May 26, 2023 at 9:38
1

In my case the file .npmrc was corrupt. After deleting it everything worked.

2
  • where .npmrc can be found?
    – osama
    Commented Jun 1, 2022 at 21:01
  • In your home directory Commented Jun 4, 2022 at 21:32
1

I was getting the same error, but I was able to resolve it by the below described method:

Go to folder -> Local > npm-cache and delete all contents of the npm-cache. try again with npm command, it should work now.

1

I solved this by update npm from 6.x to 8.5x, then run npm cache clear --force, npm install, however, it has to change the nodejs from 14 to 17, my env is macOS m1 pro.

1

I was getting this error from an old branch that had a previous version of node/npm. using the correct version of node helped in my case.

0

If you were encountering this problem while using NPM workspaces, try removing all of the node_modules directory that is not the root one. Such as:

$ rm -rf packages/*/node_modules
$ npm install
-1

I solved deleting node_modules and running this command:

npm cache clear --force

Not the answer you're looking for? Browse other questions tagged or ask your own question.