Npm Error - Windows NT - How to resolve

2019-04-24 10:48发布

问题:

I get the following error when I try npm install :

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs
\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v0.10.36
npm ERR! npm  v2.12.1

npm ERR! Cannot read property 'latest' of undefined
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs
\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v0.10.36
npm ERR! npm  v2.12.1

npm ERR! Cannot read property 'latest' of undefined
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs
\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v0.10.36
npm ERR! npm  v2.12.1

npm ERR! Cannot read property 'latest' of undefined
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

What is wrong? I cant use nodejs < 0.10.36 or > 0.11

回答1:

You may want to point to a local registry or a registry behind the firewall

npm install --registry http://npm.myserver.com


回答2:

Change your location of cache. This will definitely work. By default NPM tries to pickup packages from cache and the default location is sometimes prohibited from reading.

npm config set cache C:\Dev\nodejs\npm-cache --global

Cheers!



回答3:

Updating npm solved the problem for me. npm install -g npm



回答4:

Culprit: Windows real time protection

Turn off the real time protection of Windows Defender (or any other anti-virus) and you will be good to go. I spent a lot of time finding this simple solution but it really works.



回答5:

Seems it is a certificate expire issue with:

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

in stead run:

npm set registry http://registry.npmjs.org/

or else run:

npm install -g npm

This helped me!



回答6:

Problem caused by my corporate proxy. Here is solution that worked for me: In the

"C:\Users\USERNAME"

Edit/Create

.npmrc

file with next structure:

registry=https://registry.npmjs.org/
proxy=http://192.168.10.10:1180/
https-proxy=http://192.168.10.10:1180/
strict-ssl=false

use http regitstry if https is blocked by your corporate proxy



回答7:

You are probably behind a proxy or firewall. Ref. this issue.

To resolve the issue disable any firewall, proxy or antivirus that might interfere.



回答8:

Check the information at the log file generated at the same folder you issued the command:

cat npm-debug.log

In my case the error was related a mistake made during typing the content of the package.json:

verbose stack Error: Invalid version: "1.0"


回答9:

This error mostly occurs when you use any defender in windows or antivirus software. I have disabled Antivirus software and work right. if a problem does not solve then start your CMD administrator mode and you should point a local registry

npm install --registry http://npm.myserver.com


标签: node.js npm