In this tutorial, we are going to learn about how to install the npm packages behind the (corporate) proxy server.
For Http proxy:
Open your terminal and run the following command by replacing it with your proxy host and port.
npm config set proxy http://proxy_host:port
If your proxy contains username and password then you can run it like this:
npm config set proxy http://username:email@example.com:port
For Https proxy:
If your company provides you https proxy then you can use the following command:
npm config set https-proxy https://proxy.company.com:8080
username & password config:
npm config set https-proxy http://username:firstname.lastname@example.org:port
Now, you can install the npm packages behind the proxy by running an
npm install <package-name> command.
npm install express
You can also read, how to clear a proxy in npm.