How to configure NPM and Yarn behind proxy server

Introduction

Here we will configure Npm or Yarn to access internet through proxy server.

Steps

1. Open an command prompt or terminal session and type the following commands
npm config set proxy http://proxyserver:proxyport
npm config set https-proxy http://proxyserver:proxyport
npm config set strict-ssl false npm config set registry "http://registry.npmjs.org/"
npm --without-ssl --insecure install
Where proxyserver is your proxy server IP address and proxyport is your proxy server Port number.
For example: http://10.1.1.1:3128

For YARN, you need also to run this command
yarn config set strict-ssl false
2. Check Node Configuration by writing the following command

npm config list

The output will look like this:
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.10.1 node/v10.16.0 win32 x64"
; userconfig C:\Users\Armano\.npmrc
https-proxy = "http://proxyserver/:proxyport"
proxy = "http://proxyserver/:proxyport"
; builtin config undefined
prefix = "C:\\Users\\User1\\AppData\\Roaming\\npm"
; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\Windows\System32
; HOME = C:\Users\User1
; "npm config ls -l" to show all defaults.
 Make sure that all proxy configuration is correct, and that’s all, you can now use Npm/Yarn behind proxy server

Leave a Reply

avatar
  Subscribe  
Notify of