Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to make npm install (the command) to work behind proxy?

Tags:

node.js

npm

Read about a proxy variable in a .npmrc file but it does not work. Trying to avoid manually downloading all require packages and installing.

like image 617
Ben Avatar asked Sep 26 '11 18:09

Ben


People also ask

How do I find my npm proxy settings?

Open Settings > System > Open Proxy Settings > LAN Settings In LAN Settings you can find the proxy server and its port no.

What is npm proxy?

Central registry: an npm proxy acts as a central registry for all your required package versions. Private and public together, possibly from multiple upstream sources. Visualization of dependencies: With all required packages in one place it enables identification of a potential issues.


1 Answers

I solved this problem this way:

  1. I run this command:

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

    npm config set registry "http://registry.npmjs.org/" 
  3. Then I install packages using this syntax:

    npm --proxy http://username:[email protected]:80 install packagename 

Skip the username:password part if proxy doesn't require you to authenticate

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

EDIT2: As @BStruthers commented, keep in mind that passwords containing "@" wont be parsed correctly, if contains @ put the entire password in quotes

like image 120
Renato Gama Avatar answered Sep 20 '22 14:09

Renato Gama