简体   繁体   English

npm 在安装后/解锁时挂起

[英]npm hangs on postinstall / unlock

I have a Linux server that runs some virtual Machines using KVM.我有一台 Linux 服务器,它使用 KVM 运行一些虚拟机。 Host machine is a Debian derivate with kernel 2.6.32-32(-pve).主机是 Debian 派生的 kernel 2.6.32-32(-pve)。

In roughly 75% of the times I run npm install , it hangs while installing modules.在我运行npm install的大约 75% 的时间里,它在安装模块时挂起。 I ran it in silly debug level and it always hangs at the line我在愚蠢的调试级别运行它,它总是挂在线上

npm info postinstall [module name] (older npm versions) npm info postinstall [module name] (较旧的 npm 版本)

or或者

npm verb unlock done using [...] (newer npm versions) npm verb unlock done using [...] (较新的 npm 版本)

forever.永远。

It happens in every project on the host machine and on the virtualized systems for every node and every npm version I have tested (a lot, including the newest ones (2.7.x atm)).它发生在主机上的每个项目和每个节点的虚拟化系统上以及我测试过的每个 npm 版本(很多,包括最新的(2.7.x atm))。

It also is not deterministic.它也不是确定性的。 Sometimes it works, sometimes not and most of the times it hangs on a different module.有时它可以工作,有时不能,而且大多数时候它挂在不同的模块上。

On my dev machine (which is in the same.network, running OS X 10.10) it works fine.在我的开发机器上(在同一个网络中,运行 OS X 10.10)它工作正常。

I am not behind any kind of proxy.我不支持任何类型的代理。

What could possibly be wrong here?这里可能有什么问题?

EDIT : For the time being I solved this problem by checking in all my dependencies as gzipped files using https://github.com/JamieMason/shrinkpack编辑:目前我通过使用https://github.com/JamieMason/shrinkpack将我的所有依赖项检查为压缩文件来解决这个问题

I was having the same issue for several hours, and couldn't work out what the problem was.我在几个小时内遇到了同样的问题,但无法弄清楚问题是什么。 I tried re-installing everything a few times, manually installing individual modules, switching from x64 to x86 versions of NodeJS, etc, and got nowhere.我尝试了几次重新安装所有东西,手动安装单个模块,从 x64 版本的 NodeJS 切换到 x86 版本等,但一无所获。

In the end, I changed networks, from WiFi over ADSL2+ [~2mbps] to 4G Hotspot [~20mbps] and it worked in 30 seconds.最后,我改变了网络,从 WiFi over ADSL2+ [~2mbps] 到 4G Hotspot [~20mbps],它在 30 秒内工作。 No idea why, since it didn't seem like a network speed issue, but it solved the problem.不知道为什么,因为它看起来不像是网络速度问题,但它解决了问题。

Hope this helps someone else, too!希望这对其他人也有帮助!

I had the same problem on our Jenkins slaves based on Ubuntu, and it was solved by upgrading npm .我在基于 Ubuntu 的 Jenkins slave 上遇到了同样的问题,通过升级npm解决了。

Default npm installed by apt-get has version 1.3.10 now, which is very old (shown by npm --version ). apt-get安装的默认npm现在版本为1.3.10 ,这是非常旧的(由npm --version )。 There are at least two ways to upgrade it:至少有两种方法可以升级它:

  1. Run sudo npm install -g npm command.运行sudo npm install -g npm命令。 If you want to install a specific version you can run append it at the end of command: sudo npm install -g npm@2.1.3 .如果要安装特定版本,可以在命令末尾运行 append 它: sudo npm install -g npm@2.1.3
  2. Or you could add NodeSource repositories using these instructions and run usual sudo apt-get update .或者您可以使用 这些说明添加 NodeSource 存储库并运行通常的sudo apt-get update

I have the same problem on Windows .我在Windows上有同样的问题。 I deleted my npm-cache folder and reinstalled npm .我删除了我的npm-cache文件夹并重新安装了npm Everything started working normally after that.之后一切都开始正常工作。 The npm-cache folder can be found at可以在以下位置找到npm-cache文件夹

<your-drive>\Users\<your-name>\AppData\Roaming\npm-cache

Remember to turn on 'View hidden files because the AppData folder by default is hidden记得打开“查看隐藏文件,因为 AppData 文件夹默认是隐藏的

You can reinstall npm by using the command,您可以使用以下命令重新安装 npm,

npm i npm -g

我做了同样的事情,将我的网络从 WiFi 切换到 3G 并且它工作正常。

I'm experiencing the same problem, this is the issue on Github: https://github.com/npm/npm/issues/7862我遇到了同样的问题,这是 Github 上的问题: https : //github.com/npm/npm/issues/7862

There are some useful tips that seemed to help a few people.有一些有用的提示似乎对一些人有所帮助。

For me doing $ npm install -g node-gyp (as suggested here: http://gangmax.me/blog/2013/05/13/resolve-npm-update-node-gyp-hung-problem/ ) fixed the problem.对我来说,做 $ npm install -g node-gyp(如这里建议的那样: http : //gangmax.me/blog/2013/05/13/resolve-npm-update-node-gyp-hung-problem/ )解决了这个问题.

I had the same problem and just run我有同样的问题,只是运行

npm cache clean

And it works!它有效!

Had this same problem in Windows.在 Windows 中也有同样的问题。 The solution was to restart after installing node and npm and then run command prompt as administrator.解决方案是在安装 node 和 npm 后重新启动,然后以管理员身份运行命令提示符。

On Windows make sure you are in a native CMD (not in VSCODE or whatever IDE).在 Windows 上,请确保您使用的是本机 CMD(不在 VSCODE 或任何 IDE 中)。 Also, try increasing the max memory limit for node:另外,尝试增加节点的最大内存限制:

set NODE_OPTIONS=--max_old_space_size=8096 

In my case, a system restart did the work.就我而言,系统重启完成了工作。 I ran npm install --verbose which suggested some lock on a file in npm-cache .我运行npm install --verbose ,它建议对npm-cache的文件进行一些锁定。 And I think the system released the file (which was under use) after the system restart.而且我认为系统在系统重新启动后释放了该文件(正在使用)。 I am using windows.我正在使用窗户。

再次尝试克隆项目并执行 npm i

"

I ran into this with npm v6, and it turned out I was just being impatient.我用 npm v6 遇到了这个,结果证明我只是不耐烦。 I just needed to wait a little longer and it proceeded to the next step.我只需要再等一会儿,它就会进入下一步。

npm cache clean --force 

works for me:)为我工作:)

=> this method working with me When npm block 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更改环境变量中的路径 C:\\Users[username]\\AppData\\Roaming\\npm\\node_modules2

  • Run the your command to install your package .运行你的命令来安装你的包。

  • open file explorer copy the link C:\\Users[username]\\AppData\\Roaming\\npm\\node_modules打开文件资源管理器复制链接 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. ok 文件 yourpackage.CMD 创建了另一个文件夹在 node_modules 中创建了“node_modules2”并包含您的包文件夹。

  • copy your package file CMD to parent folder "npm"将您的包文件 CMD 复制到父文件夹“npm”

  • copy your package folder to parent folder "node_modules"将您的包文件夹复制到父文件夹“node_modules”

  • now run npm config set prefix C:\\Users[username]\\AppData\\Roaming\\npm现在运行 npm config set prefix C:\\Users[username]\\AppData\\Roaming\\npm

  • change the Path in Environment Variables set C:\\Users[username]\\AppData\\Roaming\\npm更改环境变量中的路径 C:\\Users[username]\\AppData\\Roaming\\npm

  • now package working correctly with Command line现在包可以使用命令行正常工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM