NPM Cannot read property '0' of undefined

I had the same problem.

I removed both node_modules and package-lock.json and then did:

npm install 

And it worked.

Edit by @OwlyMoly Due to new updates and the restriction to old dependencies in package-lock.json is causing this conflicts. By doing npm install won't fix this issue. Instead by ditching npm_modules and package-lock.json and doing npm install will load a new node_modules and that supposed to be required by package.json. You have to commit the new package-lock.json along with your latest changes of the project.


Just download and install latest Yarn which is also a node package manager, developed by facebook, but has a much better dependency management. Also update your node cli (optional).

And then, install your dependencies using yarn:

yarn install

or

yarn // short version of yarn install

No errors!

You can continue to use npm after you have installed all dependencies with yarn or continue with yarn....it's your choice.


Do 2 steps bellow (Window):

rm -rf ./node_modules to remove node folder

rm package-lock.json to remove package-lock.json file

then npm install to re-install the node modules

Tags:

Npm