NPM Cannot read property '0' of undefined

2019-04-18 01:36发布

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 ?

标签: npm
8条回答
Viruses.
2楼-- · 2019-04-18 02:19

Try with nvm(Node Version Manager).it help you to install any node version for any project without any Error.

查看更多
仙女界的扛把子
3楼-- · 2019-04-18 02:27

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.

查看更多
我命由我不由天
4楼-- · 2019-04-18 02:34

I've made some tests:

nodejs@8.6.0 npm@5.5.1 - I have trouble and the test fails

nvm use 8.5.0

nodejs@8.5.0 npm@5.5.1 - I have trouble and the test fails

nvm use 8.4.0

nodejs@8.4.0 npm@5.5.1 - I have trouble and the test fails

npm install npm@^5 -g

nodejs@8.4.0 npm@5.4.2 - I have trouble and the test fails

nvm use 8.6.0
npm install npm@^4 -g

nodejs@8.6.0 npm@4.6.1 - no trouble, this fixes it.

查看更多
Juvenile、少年°
5楼-- · 2019-04-18 02:34

npm 5.3.0 is broken for windows 10 after upgrading the nodeJS.
You should downgrade the npm, it is a temporary solution but works fine.

npm install -g npm@5.2.0

查看更多
该账号已被封号
6楼-- · 2019-04-18 02:36

Seems to be an issue with a combination of factors.

Some workarounds here:

https://github.com/npm/npm/issues/18238

查看更多
Emotional °昔
7楼-- · 2019-04-18 02:38

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

查看更多
登录 后发表回答