After updated Node (upto v8.6.0) and npm (upto v5.5.1) I cannot execute command npm install
.
After npm install I've error message:
npm ERR! Cannot read property '0' of undefined
What's trouble or I need downgrade node/npm ?
The "Cannot read property '0' of undefined" error occurs when trying to access the 0th index in a variable that stores an undefined value. Make sure to initialize the variable to the correct type, e.g. array or string, before accessing the index.
To solve the "Cannot read properties of undefined" error, make sure that the DOM element you are accessing exists. The error is often thrown when trying to access a property at a non-existent index after using the getElementsByClassName() method. Copied! const boxes = document.
What Causes TypeError: Cannot Read Property of Undefined. Undefined means that a variable has been declared but has not been assigned a value. In JavaScript, properties and functions can only belong to objects.
The "Cannot read property '0' of null" error occurs when trying to access the 0th index on a variable that stores a null value. Before you access the index, make sure that the value allows for index access, e.g. is of type array or string.
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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With