Is there a way to make npm install (command) work behind a proxy?
P粉743288436
P粉743288436 2023-08-23 18:07:57
0
1
596
<p>Read the proxy variable in the <code>.npmrc</code> file but it doesn't work. Try to avoid manually downloading and installing all required packages. </p>
P粉743288436
P粉743288436

reply all(1)
P粉775723722

I solved the problem like this:

  1. I run this command:

    npm config set strict-ssl false
    
  2. Then set npm to run using http instead of https:

    npm config set registry "http://registry.npmjs.org/"
    
  3. Then I install the package using the following syntax:

    npm --proxy http://username:password@cacheaddress.com.br:80 install packagename
    

If the proxy does not require you to authenticate, skip the Username:Password section

EDIT: A friend of mine just pointed out that you can get NPM to work behind a proxy by setting the BOTH HTTP_PROXY and HTTPS_PROXY environment variables and then issuing the command normally npm install express(for example)

Edit 2: As @BStruthers commented, please remember that passwords containing "@" will not parse correctly, if it contains @, put the entire password in quotes

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template