While working with NodeJs you’ll notice that many a times you might not be able to install or update while working behind a proxy network like the corporate web proxy of your office etc. Basically you might notice that the commands like npm install is not working. However, this can be easily fixed by setting the proxy of NodeJs using config command. You would have to set the proxy for both http and https proxy.

In NodeJs the npm uses a configuration file which can be easily edited using the npm config edit command. You can use that to set the proxy values directly into the file. As an alternative you can also use the npm config set <key> <value> command to set the http-proxy value. Following is the code you would require to set the proxy using the npm config in NodeJs :

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

If your network requires a username password then please pass it in like :
npm config set https-proxy http://username:[email protected]:8080

Also remember to you might have to url encode the proxy url if there are special character in it . Especially if you have characters like “@” within your password, you might have to replace it with relevant ASCII code.

Related Posts

  • Load Timeout for Modules Error in RequireJs RequireJs is a very helpful JavaScript Module Loader. If you've been working on BackboneJS, AngularJs or KnockoutJs you would have most likely come across RequireJs. […]
  • How to implement Cufon fonts ? The web is getting creative and beautiful. You can find  a variety of new font's being used across the web making the site look beautiful and creative. There are […]
  • How to make placeholder work in IE ? One of the interesting features of HTML5 is the "placeholder" attribute. This new attribute has helped web developers save a lot of time as without it we would have had […]
  • How to Minify a Javascript File? The web technology today has improved dramatically and the way scripting is done on websites have changed drastically over the years now. Gone are the days when […]
  • What is a constructor in Javascript ? If you have been working on or learning Object Oriented JavaScript, you must have come across the word "constructor" a number of times. A constructor is basically a […]
  • How to disable autocomplete in HTML? The autocomplete feature has been of a great help as a website visitor especially if you have a long form that you might fill more than once. The autocomplete feature […]