npm install command freezes during execution

I’m having trouble with my Node.js project setup. Here’s what my package.json looks like:

{
  "name": "sample-project",
  "version": "1.0.0",
  "dependencies": {
    "axios": "^1.0.0",
    "lodash": "4.17.x",
    "moment": "~2.29"
  }
}

Whenever I try to run npm install in my terminal, the process just gets stuck and doesn’t complete. It doesn’t show any error messages, it just hangs there indefinitely. I’ve waited for over 10 minutes but nothing happens. Has anyone encountered this issue before? I’m not sure what could be causing this problem or how to fix it.

same thing happened to me yesterday! my internet was dropping packets randomly. npm just hangs forever when the network acts up. try npm install --network-timeout 60000 - it’ll timeout faster and retry. also restart your router if it’s acting weird, that fixed mine.

This happens to me all the time, especially on corporate networks. Usually it’s proxy settings or DNS issues that npm can’t handle well. First, check if you’re behind a corporate firewall or VPN that’s blocking npm requests. Run npm install --timing to see exactly where it gets stuck - it usually hangs when fetching metadata. I’ve had luck switching to a different DNS server like 8.8.8.8 or using npm install --prefer-offline if you’ve got cached packages. On Windows, antivirus sometimes messes with npm’s file operations. Try disabling real-time protection during install (just remember to turn it back on).

Check your npm version with npm --version. I encountered the same problem last month—an older version of npm had a dependency resolution bug. Upgrading fixed it for me using: npm install -g npm@latest. Additionally, verify if there are any conflicting global packages using npm list -g --depth=0, as outdated globals can make installs hang during the resolution process. If upgrading doesn’t resolve the issue, create a fresh directory containing just your package.json to see if there’s something in your project folder causing the hang.

npm installs freeze because of network or cache problems. Try this:

Clear your cache:

npm cache clean --force

Nuke node_modules and the lock file:

rm -rf node_modules package-lock.json

Reinstall with verbose logging:

npm install --verbose

Still hanging? Switch registries:

npm install --registry https://registry.npmjs.org/

Honestly though, I got tired of fighting npm. Now I use automated workflows that handle dependencies, environment setup, and deployments without babysitting package managers.

The workflow watches installs and auto-retries with different approaches when things hang. Sets up my whole dev environment in one shot.

Saves me hours weekly and kills these freezing problems.

Check out Latenode to simplify your setup: https://latenode.com