How to use npm behind a proxy

NPM Logo

Coding some examples from the book Arquitecturas Web con Angular.js about setting up a basic web server using Node.js and Express.js and i needed to install Express.js on my project. At the moment i’m in corporate environment and we are behind a proxy. So, i tried to install Express using npm with this command:

And i got this error:

Because of the proxy. So, how do you configure npm to work behind a proxy?

Searching on internet i found this article which explains perfectly how to configure a proxy on npm. You have to set configuration parameter proxy or https-proxy:

Be careful about using the URL schema. First i wrote this (a normal proxy, without an https one, and a fake IP 😛 ):

And when i tried the same command npm install express i got this error:

So, after setting proxy in the right way, everything worked as desired: