node.js NPM 不安装任何东西:它挂起

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20047008/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 16:17:54  来源:igfitidea点击:

NPM does not install anything : it hangs

node.jsnpm

提问by Videl

Whenever I want to install a module with NPM, it hangs at that stage:

每当我想用 NPM 安装一个模块时,它就会挂在那个阶段:

npm install express
npm http GET https://registry.npmjs.org/express

And that's it. It has that behavior for anything I input instead of express. I installed nodejsand nvmthat way (Ubuntu 13.10):

就是这样。对于我输入的任何内容而不是express,它都有这种行为。我这种方式安装了nodejsnvm(Ubuntu 13.10):

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

I tried looking on the Internet and GitHub and I found a closed issue about npm hanging forever when trying to install a module.. but it was a really old issue. Before I ask the developers, am I missing something obvious ?

我尝试在 Internet 和 GitHub 上查找,发现了一个关于 npm 在尝试安装模块时永远挂起的封闭问题。但这是一个非常老的问题。在我问开发人员之前,我是否遗漏了一些明显的东西?

I tried compiling both nodejs and npm but the result was the same.

我尝试同时编译 nodejs 和 npm,但结果是一样的。

EDIT: npm install express -verbose-> http://pastebin.com/tGY3V6LyError:

编辑:npm install express -verbose-> http://pastebin.com/tGY3V6Ly错误:

npm info retry will retry, error on last attempt: Error: tunneling socket could not be established, cause=140072708810560:error:140770FC:SSL   routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:766:

回答by Munim

NPM has been having server issues of late. Try running the command with -verboseto check and see what is going on, and be patient.

NPM 最近一直有服务器问题。尝试运行命令-verbose以检查并查看发生了什么,并耐心等待。

回答by Eric

I had this issue on a BeagleBone Black (low power ARM device) and running npm cache clean seemed to get things moving again.

我在 BeagleBone Black(低功耗 ARM 设备)上遇到了这个问题,运行 npm cache clean 似乎让事情再次发生了变化。

回答by Anjum....

Try without https:

尝试没有https

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

回答by Mika Yoshiaki

I had the same issue and I solved by disabling all my firewalls

我遇到了同样的问题,我通过禁用所有防火墙解决了

回答by saman.shahmohamadi

After an hour of struggling, I cleaned .npmand node_modesl/.stagingdirectories, and problem just gone! (replace the paths with your own)

挣扎了一个小时后,我打扫.npmnode_modesl/.staging目录,问题只是走了!(用您自己的路径替换路径)

yes|rm /root/.npm/* -R
yes|rm /path/to/node_modules/.staging/* -R
npm install

yes|rm /root/.npm/* -R
yes|rm /path/to/node_modules/.staging/* -R
npm install

回答by Samuel James

I opened console with admin privileges and the ran npm installon windows. My problem was fixed with this

我以管理员权限打开控制台,然后npm install在 Windows 上运行。我的问题已解决

回答by minigeek

It is likely of proxy problem. I didn't set proxy but somewhow this worked for me

很可能是代理问题。我没有设置代理,但不知何故这对我有用

npm config delete proxy
npm config delete https-proxy
npm set registry https://registry.npmjs.org/

回答by Cormac O'Keeffe

I was using an older version of node. I used a newer version Type in Terminal:

我使用的是旧版本的节点。我在终端中使用了较新的版本类型:

nvm use stable

and then

进而

npm i

and all worked just fine.

一切都很好。

回答by Paul Razvan Berg

For me, this is what worked:

对我来说,这是有效的:

npm cache clean

And then I reloaded the terminal window and ran npm installagain.

然后我重新加载了终端窗口并npm install再次运行。

回答by feeeper

I had the same error and the problem was in proxy: previously I set up HTTP_PROXYenvironment variable and after removing it npm installcompleted without any error.

我有同样的错误,问题出在代理中:以前我设置了HTTP_PROXY环境变量,删除npm install后没有任何错误。