NPM package installation fails with ETimedOut error on Windows proxy network

Help! NPM install keeps timing out on my work computer

I’m trying to set up a new project, but I’m running into a roadblock. Every time I try to install packages globally with NPM, it fails. Here’s what’s happening:

  1. I run npm install -g yo in the command prompt
  2. After a while, I get an ETimedOut error
  3. There’s a warning about proxy settings

I think it might be related to the network at my office. We use a proxy to access the internet. Does anyone know how to fix this? I’ve looked in the NPM docs, but I’m not sure what settings I need to change.

Has anyone else run into this problem before? Any tips on how to configure NPM to work with a corporate proxy would be super helpful. Thanks in advance!

I’ve encountered similar issues in corporate environments. One thing that often helps is manually setting the registry URL. Try running:

npm config set registry http://registry.npmjs.org/

This forces npm to use the official registry directly. If that doesn’t work, it might be necessary to configure npm to use a local cache. Set up a directory for the cache with:

npm config set cache C:\npm-cache

Then, when installing packages, use the --cache flag:

npm install -g yo --cache C:\npm-cache

These steps have helped resolve timeout issues in environments with strict corporate firewalls and proxies. If problems persist, consider consulting your IT department for any specific npm configurations needed for your network.

hey pete, ive had this issue too. try setting the npm registry to a mirror:

npm config set registry https://registry.npm.taobao.org

this worked for me when my company proxy was being weird. if that doesnt help, maybe check with ur IT dept? they might need to whitelist some npm urls or smthn

I’ve definitely been in your shoes before, Pete. Corporate proxies can be a real pain when it comes to npm installs. Here’s what worked for me:

First, try setting the proxy configuration directly in npm. Open your command prompt and run:

npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080

Replace the URL and port with your company’s actual proxy details. You might need to check with IT for the correct information.

If that doesn’t do the trick, you could also try adding these settings to your system’s environment variables. Sometimes npm doesn’t pick up the global settings correctly.

Another thing to consider is increasing the timeout. You can do this by running:

npm config set fetch-retry-maxtimeout 120000

This sets the max timeout to 2 minutes, which might help if your proxy is just slow.

Hope this helps you get up and running!