node.js npm 安装挂起
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16873973/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
npm install hangs
提问by user1090227
This is my package.json:
这是我的package.json:
{
"name": "my-example-app",
"version": "0.1.0",
"dependencies": {
"request": "*",
"nano": "3.3.x",
"async": "~0.2"
}
}
Now, when I open the cmd and run npm install, the install hangs. What am I doing wrong?
现在,当我打开 cmd 并运行时npm install,安装挂起。我究竟做错了什么?
回答by Harshil Lodhi
I had the same problem. The reason - wrong proxy was configured and because of that npm was unable to download packages.
我有同样的问题。原因 - 配置了错误的代理,因此 npm 无法下载软件包。
So your best bet is to the see the output of
所以你最好的选择是查看输出
$ npm install --verbose
and identify the problem. If you have never configured proxy, then possible causes can be
并找出问题所在。如果您从未配置过代理,那么可能的原因可能是
- Very outdated npm version.
- Some problem with your internet connection.
- Permissions are not sufficient for npm to modify files.
- 非常过时的 npm 版本。
- 您的互联网连接有问题。
- 权限不足以让 npm 修改文件。
回答by Steve W
I was having the same problem. I tried a
我遇到了同样的问题。我试过了
npm config set registry http://registry.npmjs.org/
to turn off https. I also tried
关闭https。我也试过
npm set progress=false
to turn off the progress bar (it has been reported to slow down downloads).
关闭进度条(据报道它会减慢下载速度)。
The problem was with my network driver. I just needed to reboot and the lag went away.
问题出在我的网络驱动程序上。我只需要重新启动,滞后就消失了。
回答by imaliazhar
You can try deleting package-lock.jsonand running npm installafterwards.
This worked for me.
您可以尝试删除package-lock.json并稍后运行npm install。这对我有用。
回答by pinei
I am behind a corporate proxy, so I usually use an intermediate proxy to enable NTLM authentication.
我支持公司代理,因此我通常使用中间代理来启用 NTLM 身份验证。
I had hangs problem with npm install when using CNTLM proxy. With NTLM-APS (a similar proxy) the hangs were gone.
使用 CNTLM 代理时,我遇到了 npm install 挂起问题。使用 NTLM-APS(类似的代理),挂起就消失了。
回答by Mohamed sami Khiari
This method is working for me when npm blocks in installation Package for IONIC installation and ReactNative and another package npm.
当 npm 在用于 IONIC 安装和 ReactNative 的安装包和另一个包 npm 中阻塞时,此方法对我有用。
You can change temporary:
您可以临时更改:
npm config set prefix C:\Users\[username]\AppData\Roaming\npm\node_modules2
npm config set prefix C:\Users\[username]\AppData\Roaming\npm\node_modules2
Change the path in environment variables. Set:
C:\Users[username]\AppData\Roaming\npm\node_modules2
Run the command to install your package.
Open file explorer, copy the link:
C:\Users[username]\AppData\Roaming\npm\node_modules
ok file yourpackage.CMD created another folder Created "node_modules2" in node_modules and contain your package folder.
Copy your package file CMD to parent folder "npm".
Copy your package folder to parent folder "node_modules".
Now run:
npm config set prefix C:\Users\[username]\AppData\Roaming\npmChange the path in environment variables. Set:
C:\Users[username]\AppData\Roaming\npm
更改环境变量中的路径。放:
C:\Users[用户名]\AppData\Roaming\npm\node_modules2
运行命令来安装你的包。
打开文件资源管理器,复制链接:
C:\Users[用户名]\AppData\Roaming\npm\node_modules
ok 文件 yourpackage.CMD 创建了另一个文件夹在 node_modules 中创建了“node_modules2”并包含您的包文件夹。
将您的包文件 CMD 复制到父文件夹"npm"。
将您的包文件夹复制到父文件夹"node_modules"。
现在运行:
npm config set prefix C:\Users\[username]\AppData\Roaming\npm更改环境变量中的路径。放:
C:\Users[用户名]\AppData\Roaming\npm
Now the package is working correctly with the command line.
现在该软件包可以在命令行中正常工作。
回答by Payal
The registry(https://registry.npmjs.org/cordova) was blocked by our firewall. Unblocking it fixed the issue.
注册表 ( https://registry.npmjs.org/cordova) 被我们的防火墙阻止。取消阻止它解决了这个问题。
回答by Kayo
Incase its useful to others, the following is what worked for me:
如果对其他人有用,以下对我有用:
On my machine, although npm proxy was set correctly, npm installwaits forever doing something like sill extract. Re-trying npm installwaits forever on the same package again and again.
在我的机器上,尽管 npm 代理设置正确,但npm install会永远等待执行诸如 sill extract 之类的操作。重试npm install一次又一次地等待同一个包。
After waiting for a long timeout, npm installprinted an error message implying that gitwas trying to fetch something.
等待很长时间后,npm install打印了一条错误消息,暗示git正在尝试获取某些内容。
The problem vanished after configuring gitproxy using the below command:
使用以下命令配置gitproxy后问题消失:
git config --global http.proxy https://proxy-server:port
Note the httpsin the valueof http.proxywithout which the configuration did not take effect. Proxy server settings (http / https / port) might vary for users; hence its worth spending a bit of time experimenting with npmand gitproxy server settings.
注意https在值中http.proxy没有它的配置并没有生效。代理服务器设置(http / https / 端口)可能因用户而异;因此值得花一些时间来试验npm和git代理服务器设置。
回答by SUSHIL MANKAR
I just turn off my windows firewall and it worked for me. You can also try different versions of npm.
我只是关闭了我的 Windows 防火墙,它对我有用。你也可以尝试不同版本的 npm。
回答by michael
When your ssh key is password protected run ssh-add. npm probably hangs somewhere asking for your password.
当您的 ssh 密钥受密码保护时,运行ssh-add. npm 可能挂在某个地方要求您输入密码。
回答by Pier-Luc Gendreau
While your mileage may vary, running npm cache verifyfixed the issue for me.
虽然您的里程可能会有所不同,但跑步npm cache verify为我解决了这个问题。

