-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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 hangs for ~2 minutes with optional dependencies in npm 10.9.0 #7900
Comments
Just to clarify why using non-existing packages in optionalDependencies is a valid real-world scenario: This pattern is commonly used when packages are optionally required based on environment. Some examples:
In all these cases, npm should gracefully skip unavailable optional dependencies rather than hanging. The 2-minute delay makes the development experience significantly worse, especially in CI/CD environments where multiple clean installs might be required. |
I think I am hitting this issue too. I'm running an install using gitlab-ci-local. It's using npm 10.9.0 (node:22-bookworm). For me, it never finishes (I killed it after 5m). For me, it hangs in idealTree. I ran it using npm 10.8.3 and placed both outputs side-by-side. |
This is a duplicate of #4028 |
Which are also the same issue and on both it is either reported as starting in either 10.4.0 or 10.9.0, it is all an issue in the Try to run your command with |
I encountered a similar issue, while in my case The workaround that worked for me is setting
It's not a pretty solution, and maybe it's not the same issue as described here, but it also hung upon Node version: 22.11.0
Hope this is helpful for others. |
Based on testing on windows with node 23 and npm 10.9.0, I did not encounter the npm install hanging issue. Try using the node 23 to see if it resolves the issue. |
I'm keen on using LTS versions only, so even if that solves the issue, it's not a good solution until it would land in node 22 as well. |
@paulrutter It wasn't suggestion to use non LTS version, but just to test if your case is still reproduced on this version in order to help triage |
Sorry, i misunderstood. I can try that next week. |
@paulrutter your issue is the only one that seems different from this issue and all the other linked issue, especially given the fact you still had it on 10.3.0 |
Yes, true. I suspect it's an issue with that specific dependency, hence i also created an issue there. |
@Guria This should be fixed in npm 10.9.1, could you try that and confirm? |
Thanks, I've checked and can confirm that my case is solved with 10.9.1 |
This is to include fix for this annoyance: npm/cli#7900
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
When using npm 10.9.0, npm install hangs for approximately 2 minutes during the idealTree phase when package.json includes optional dependencies that return 404. The same package.json installs in ~5s with npm 10.8.2.
npm hangs during the idealTree phase for ~2 minutes
Eventually completes successfully
Time measurement: npm install takes 2+ minutes
Detailed logs and measurements can be found in repro repository
Expected Behavior
Quick failure/skip of optional dependencies
Similar to npm 10.8.2 behavior which completes in ~5s
Steps To Reproduce
Repository with minimal reproduction: https://github.com/Guria/npm10.9.0-hang-repro
Create package.json:
Steps to reproduce:
Environment
OS: Linux (Manjaro 6.10.13-3)
npm: 10.9.0
unaffected npm: 10.8.2
Node.js: both behaviors confirmed on v20.18.0 and v22.11.0
Additional versions checks
Issue reproduces with npm@10.9.0 on all recent node versions:
No issue with npm@10.8.2 on all above versions.
The text was updated successfully, but these errors were encountered: