-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] npm install will randomly hang forever and cannot be closed when this occurs #4028
Comments
If there was ever a linked example on "How to report an issue", this would probably be it. |
I was getting this error last night. It seemed as though all NPM operations were going slow and/or hanging. I tried reinstalling Node/NPM/etc. Not sure if it's related, but last night I also noticed that the NPM site was taking a while to pull up. It finally seemed to clear itself up about an hour ago and everything has been working for me since. I'm guessing it was something server-side, though NPM's status page doesn't show anything as of yet. |
I'm not sure if that's the same thing. If it were network connection related, I'd assume it would time out at some point. I'd certainly expect to be able to cancel out of the process. |
I would have expected a network connection timeout too, but I waited well over an hour (for things that normally take a minute or less) and the process just sat frozen with a partial progress bar. I was, however, able to cancel out of the process on Windows Terminal, which seems to be the only difference. I even tried a different machine with a different version of Node/NPM (on a different network in a different city) during that time and it had similar issues (i.e., taking a couple minutes to run |
I've been having the same problem once in a while: npm install is stuck and I can't cancel the process. For the last few months, this happened rarely, and when it happened I had to restart my laptop to get it working again. Last week I updated Node from 14 to 16, and npm from 6 to 8. Everything seemed fine until today... However, today I can't get npm install to finish, not even once. I tried
Note: it's not always the same dependency that it gets stuck at. What I've found that seems strange is that as it fetches dependencies it starts getting progressively slower, until it gets stuck (when the timing gets about 30-45 seconds).
Maybe relevant - I have a few private scoped packages configured in npmrc
though it doesn't seem to get stuck on them
I've tried setting It seems today is not a good day for developing 😢 Windows 10 21H1 build 19043.1348 Edit: tried uninstalling node completely, cleaning everything up and reinstalling, but it didn't work ... still stuck |
After trying all day to reinstall and make npm work I ended up:
This actually worked, although slowly, it never got stuck I have no idea why even after purging every reference to node or npm from my laptop and doing a fresh install, it still didn't work on Windows. |
I've been running into this as well. Happens on npm is latest version (8.3) I did just recently update from npm 6.x to latest. One thing I note is the warning message saying package-lock.json is out of date and needs to be rewritten (one-time operation). For smaller projects, it squeaks by but only after many periods of CPU lock ups and spending more time than it used to with npm version 6.x. For bigger projects, the only new observation I can add is that the number of node processes running simultaneously explodes, and they are all hogging the CPU and memory. So now memory swap processes enter the mix and the whole computer grinds to a halt. Eventually I have to |
I'm having a similar issue after upgrading to node 16.13.1 and npm 8.3.0 (running on centos 7) After I downgraded npm back to version 6.14.15 ( npm install -g npm@6 ), the "npm install" completes quickly and successfully. |
With 8.3.0, I got by installing all the dependencies of my larger projects by running It appears if you try to install multiple large dependencies at once, there is a greater probability of parallel |
In my case it was network related. I had a private registry in |
Seeing this as well on a Mac. |
I am getting this error as well on a windows PC using the command prompt (cmd.exe). I've tried the following combinations and was able to reproduce the stuckness each time (I was using nvm for windows to switch versions): node v16.13.1 / npm 8.1.2 I do have AV Defender installed, which I can't disable due to it being a company installed anti-virus software. I was also running Fiddler4 and haven't seen any HTTP errors related. I then switched to a git bash terminal and was able to run My git version installed on windows was |
I'm documenting my adventures in npm. Never occurred to me to switch from ZSH to Bash or use Git Bash. Good post! |
Thanks. I was also able to reproduce the stuckness using PowerShell too. Now if I could figure out how to get my azure pipeline to run git bash I'll be golden. I'm going to try to use the bash task https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/bash?view=azure-devops |
In case anyone is having this issue when running azure pipelines with a self-hosted agent. Below is a solution that worked for me. The only requirement for the server/computer that is running the pipeline is to have git for windows installed so you can access the sh.exe
|
I have also been seeing this issue since NPM 8 (initially on Node.js 14 and more recently on Node.js 16), Windows 10 It is kind of intermittent, seems to happen more frequently on Bash (from Git for Windows) than PowerShell or CMD The only workaround I have been able to identify is a complete restart of the system, manually delete |
I've found the reason and a workaround for my particular scenario. In my case, I had a dependency on a package from a git repo, which also had a git repo dependency, and it set off an I've logged the specific bug, proposed solution and workaround here: npm/pacote#127 (comment) |
I have this problem for a while now. I thought it that was some problem with my project's node_modules or npm version mismatch problem. Just now, I tried to install one package globally, and encountered exact same problem. not sure if this helps: with
And this is only one package (bigger one, with dependencies). |
@jumpmouse npm 8.1.4 is very old; can you try with v8.5.3? |
@ljharb thanks, I've updated to 8.5.3 Unfortunately, same behavior. It runs fast, then slows down and freezes. |
I've had no issue since posting. I was able to narrow down one issue an old wdio and current webdriverio package installed. I removed the sync (fibers) package as well. Then I used ncu to find conflicting package versions. Then ncu -u to update the package. Followed by npm i to create the package-lock. Aside from an occasional unexplained issue with a port-in-use package, my Mac has been relatively stable ever since. Hope this helps. |
similar issue on windows10 and took nearly more than one hour to complete
|
We have multiple developers in our org (mostly on Macs) also seeing issues like this after going to Node 16. |
I think this is a duplicate of #3078, the fix for this was released in npm v8.6.0 |
In my experience, this behavior ocurrs when execute I hope this can help you guys. Best regards from El Salvador. |
|
Thanks a lot to mention the Now, I wonder why this happens. Please, if anyone knows, I would greatly appreciate it the explanation. |
The actual problem is with the puppeteer version: The actual fix is to upgrade puppeteer to the version >= 22 this will solve the issue |
@abine-praveen . Thanks it worked. |
Sorry, I should have checked in as well. Upgrading puppeteer to >=22.0 was also our solution. Havent explored why 21 causes the issue though. theres an issue open puppeteer/puppeteer#12833 |
FWIW I have a feeling the CI/CD issues being reported here are probably unrelated to the initial report - I haven't had time to dig into it any further, but the behavior sounds different from the total deadlock initially reported |
Upgrading Puppeteer to |
I solved the hanging problem in windows by disabling "Controlled Folder Access" |
Just started running into timeout issues when running npm ci && npm run build, which seem to be related to puppeteer. Prior to a few days ago, was working without issue. Wondering if others that have recently commented on this thread are also experiencing a regression from previously working deployments? I'm currently running 21.3.8, and hesitant to upgrade. |
yes, we had our CI pipe-line which was working completely fine and it suddenly started failing and i spent 1 day to figure iut the problem and found this "The actual problem is with the puppeteer version: |
Puppeteer has changed the chrome download end-point, that's the reason it is failaing |
For some reason having a version of Puppeteer < 22 can cause `npm install` to hang[1]. Let's update the dependency now therefore. Note: I needed to update the dependency manually, since one of the unit tests needed to be tweaked. 1 - npm/cli#4028
For some reason having a version of Puppeteer < 22 can cause `npm install` to hang[1]. Let's update the dependency now therefore. Note: I needed to update the dependency manually, since one of the unit tests needed to be tweaked. 1 - npm/cli#4028
I'll add my solution in case it helps others. I'm building Puppeteer in Docker via AWS Codepipeline on an earlier AWS Linux OS. Like others, my CI pipeline failed around the end of July 2024. I can't upgrade puppeteer > v21 to this due to underlying dependencies (the OS can't get above Node 16.20, so Puppeteer 21 is the latest I can use). What ended up working for me was this line in my
that fixed these commands which were stalling during the chrome download step:
|
npm randomly hangs on concat-map on latest pre-release WSL2 with cleaned node_modules and package-lock... --lts or latest node version |
This is the specific issue I am able to reproduce which (to me) seems to involve DNS lookup timeouts from within the WSL environment |
npm is following the same pattern installing the pckgs... removing lastly added pckgs and re-adding in different order helped me prevent the issue.... |
You absolute legend, I would never in a million years have thought to root-cause it down to the window size. Thanks! It's a ridiculous bug, bug at least it has an insanely easy workaround. FWIW, the bug is present in 10.8.2 (the latest public release as of writing). Unclear what it's caused by, but changing terminals made absolutely no difference to me. Powershell, cmd, and even changing the terminal handler program, made no difference. Edit: I still need to add --verbose for it to work, but I went from no ability to install anything to being able to install anything very strangely, so ultimately still an improvement. |
I've been using npm 10.7.0 without a problem for a long time and yesterday, I removed node_modules and ran "npm i" and it hung. spent time yesterday looking for solutions without success. (The maximized window, cmd, PowerShell, Windows Terminal didn't work for me either). This morning I still couldn't get it to work. I just upgraded to npm 10.8.2 and it worked. Other members on my team had npm v10.7.0 and are running without a problem. There must be some external dependency that's causing a problem because I see people running into the hang problem while others with the same installed versions (node & npm) not having any problem. Windows 10 Enterprise 22H2 Build 19045.4780 Just adding a little more detail. We have about 10 web applications where we have no hangs on previous versions of npm. Another developer was using npm 10.7.0 on his own web app and was working fine, but as soon as he went to another web app, it hung. He upgraded to npm 10.8.2 and the web app where it hung now works. |
Try the combination of maximizing it, --verbose, and re-running it a few times (so caches populate). I know it sounds like one of those ridiculous unhelpful tips you see on Quora or Microsoft support forums and such, but it basically is dark magic to solve this. |
I'm writing down all the things I changed/set to solve my issue. I'm unaware of which K of N solved it, but hopefully the list is useful to people trying to chase down this super annoying issue since there's practically zero logs to root-cause it from:
After doing the above, it now works every time provided --verbose is set. More specifically:
Note that I forgot to set the strict-ssl, loglevel, etc, globally, but in the interest of communicating explicitly what I did and not some variant I'm including my errors as-is. I don't see why you couldn't use --global for all of them, but then I also don't understand the root cause of the issue so I'm leaning towards being overly specific. Then install things with (in a maximized terminal):
As an aside, I can also confirm that I am on Windows. Windows 11 Pro Version 10.0.22631 Build 22631, to be specific. |
npm just love to hang on concat-map...
|
I suspect that this is actually just coincidence. When I added the packages which depend on Btw, this happens when I remove |
So what I found out is that the process is actually completed successfully in the end, it simply takes forever (i.e. 20+ minutes). |
I have this problem at the Windows command prompt, but using a bash prompt works fine! |
@nickamckenna
|
@igortas I have the exact same issue. It can be replicated on WSL 2 Ubuntu 20.04, by running npx create-nx-workspace. |
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
When running
npm install
it will sometimes hang at a random point. When it does this, it is stuck forever. CTRL+C will do nothing the first time that combination is pressed when this has occurred. Pressing that key combination the second time will make the current line (the one showing the little progress bar) disappear but that's it. No further responses to that key combination are observed.The CMD (or Powershell) window cannot be closed regardless. The process cannot be killed by Task Manager either (Access Denied, although I'm an Administrator user so I'd assume the real reason is something non-permissions related). The only way I have found to close it is to reboot the machine.
My suspicion is it's some sort of deadlock, but this is a guess and I have no idea how to further investigate this. I've tried using Process Explorer to check for handles to files in the project directory from other processes but there are none. There are handles held by the Node process npm is using, and one for the CMD window hosting it, but that's it.
Even running with
log-level silly
yields no useful information. When it freezes there are no warnings or errors, it just sits on the line it was on. This is some log output from one of the times when it got stuck (I should again emphasise that the point where it gets stuck seems to be random, so the last line shown here isn't always the one it freezes on):The only thing that I can think of right now is that Bit Defender (the only other application running) is interfering somehow, however it's the one application I can't turn off.
I've seen this issue occur on different projects, on different network and internet connections, and on different machines. Does anyone have any advice on how to investigate this, or at the very least a way to kill the process when it hangs like this without having to reboot the machine? Being forced to reboot when this issue occurs is perhaps the most frustrating thing in all of this.
Expected Behavior
npm install
should either succeed or show an error. If it gets stuck it should either time-out or be closable by the user.Steps To Reproduce
node_modules
folder (ie with something likermdir /q /s
)npm install
Environment
The text was updated successfully, but these errors were encountered: