Here’s a properly formatted version of your question to post on Stack Overflow:
Title: npm stalls on first run, then works on second run in WSL2 Ubuntu on Windows 10
Details: I’m encountering an issue on my development setup using Windows 10 with WSL2 running Ubuntu 22.04 LTS. Whenever I run npm install, the installation fails the first time, but it works when I run it again. The issue occurs consistently, and I’m not sure how to resolve it. There are no proxies or additional firewalls on the network.
Here are my versions: • nvm: 0.40.1 • Node: 22.11.0 • npm: 10.9.0
package.json (part of it):
"devDependencies": { "react-email": "3.0.2" }
Steps to reproduce the issue:
1. Run npm cache clean --force.
2. Run npm install --verbose.
The installation will fail the first time and just hang for a long time (up to 6 hours). I then stop the process with Ctrl+C and run npm install again, and it works fine. Here’s the verbose output after it starts working.
I’m new to Node and npm, so I’m unsure of what’s causing this. Any advice or suggestions would be greatly appreciated!
What I Tried: • Running npm cache clean --force. • Running npm install --verbose multiple times. • Reinstalling npm and Node.js. • Checking network configuration in WSL2 and Windows.
What I Expect: A solution to ensure npm install works reliably on the first attempt, without needing to run it multiple times.
You can now copy and paste this directly into Stack Overflow. Be sure to include any relevant screenshots or logs where indicated.