Npm错误 – Windows NT – 如何解决

当我尝试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> 

哪里不对? 我不能使用nodejs <0.10.36或> 0.11

您可能希望指向防火墙后面的本地registry或registry

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

更改您的caching位置。 这一定会工作。 默认情况下,NPM会尝试从caching中拾取软件包,并且有时会禁止读取默认位置。

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

干杯!

更新npm解决了我的问题。 npm install -g npm

由我的公司代理造成的问题。 这是为我工作的解决scheme:在

“C:\ Users \用户名”

编辑/创build

.npmrc

文件与下一个结构:

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

如果您的公司代理阻止了https,请使用http regitstry

您可能在代理或防火墙后面。 参考。 这个问题 。

要解决该问题,请禁用可能会干扰的任何防火墙,代理或防病毒软件。

检查在您发出命令的同一个文件夹下生成的日志文件中的信息:

 cat npm-debug.log 

在我的情况下,这个错误与在inputpackage.json的内容时犯了一个错误:

 verbose stack Error: Invalid version: "1.0" 

罪魁祸首:Windows实时保护

closuresWindows Defender(或任何其他反病毒)的实时保护 ,你会很好去。 我花了很多时间find这个简单的解决scheme,但它真的有效。

似乎这是证书到期问题:

npmregistryhttps://registry.npmjs.org/

代替:

npm设置registryhttp://registry.npmjs.org/

否则运行:

npm install -g npm

这帮助了我!