This article describes a step by step solution to use NPM install command when you are working behind any corporate proxy server.
Problem
When you want to install packages for angular, angular CLI, typescript etc. via NPM using Command Prompt and you are working in an office environment where everything runs behind a corporate proxy server, you will most probably get the below exception,

Even while working on the Angular project using Visual Studio and trying to restore packages with the help of package.json, developers find the message “Package Restoring Complete” in Visual Studio title bar, but when they look for the node_modules folder inside the project folder, the node_modules folder does not exist. Developers usually find the below exception in output window of visual studio,
- === = Executing command 'npm install' === = npm WARN package.json angular - quickstart @1 .0 .0 No README data
- npm http GET https: //registry.npmjs.org/systemjs
- npm http GET https: //registry.npmjs.org/angular-in-memory-web-api
- npm http GET https: //registry.npmjs.org/core-js
- npm http GET https: //registry.npmjs.org/rxjs
- npm http GET https: //registry.npmjs.org/zone.js
- npm http GET https: //registry.npmjs.org/concurrently
- npm http GET https: //registry.npmjs.org/lite-server
- npm http GET https: //registry.npmjs.org/typescript
- npm http GET https: //registry.npmjs.org/tslint
- npm http GET https: //registry.npmjs.org/lodash
- npm http GET https: //registry.npmjs.org/jasmine-core
- npm http GET https: //registry.npmjs.org/karma
- npm http GET https: //registry.npmjs.org/karma-cli
- npm http GET https: //registry.npmjs.org/karma-chrome-launcher
- npm http GET https: //registry.npmjs.org/karma-jasmine
- npm http GET https: //registry.npmjs.org/karma-jasmine-html-reporter
- npm http GET https: //registry.npmjs.org/protractor
- npm http GET https: //registry.npmjs.org/canonical-path
- npm http GET https: //registry.npmjs.org/angular/forms
- npm http GET https: //registry.npmjs.org/angular/http
- npm http GET https: //registry.npmjs.org/angular/router
- npm http GET https: //registry.npmjs.org/angular/platform-browser
- npm http GET https: //registry.npmjs.org/angular/platform-browser-dynamic
- npm http GET https: //registry.npmjs.org/angular/core
- npm http GET https: //registry.npmjs.org/angular/compiler
- npm http GET https: //registry.npmjs.org/angular/common
- npm http GET https: //registry.npmjs.org/rimraf
- npm http GET https: //registry.npmjs.org/types/node
- npm http GET https: //registry.npmjs.org/types/jasmine
- npm http GET https: //registry.npmjs.org/rxjs
- npm http GET https: //registry.npmjs.org/systemjs
- npm http GET https: //registry.npmjs.org/core-js
- npm http GET https: //registry.npmjs.org/angular-in-memory-web-api
- npm http GET https: //registry.npmjs.org/zone.js
- npm http GET https: //registry.npmjs.org/concurrently
- npm http GET https: //registry.npmjs.org/lite-server
- npm http GET https: //registry.npmjs.org/typescript
- npm http GET https: //registry.npmjs.org/karma-chrome-launcher
- npm http GET https: //registry.npmjs.org/karma-cli
- npm http GET https: //registry.npmjs.org/lodash
- npm http GET https: //registry.npmjs.org/karma-jasmine
- npm http GET https: //registry.npmjs.org/karma
- npm http GET https: //registry.npmjs.org/karma-jasmine-html-reporter
- npm http GET https: //registry.npmjs.org/protractor
- npm http GET https: //registry.npmjs.org/jasmine-core
- npm http GET https: //registry.npmjs.org/tslint
- npm http GET https: //registry.npmjs.org/angular/platform-browser
- npm http GET https: //registry.npmjs.org/angular/platform-browser-dynamic
- npm http GET https: //registry.npmjs.org/angular/http
- npm http GET https: //registry.npmjs.org/angular/compiler
- npm http GET https: //registry.npmjs.org/types/node
- npm http GET https: //registry.npmjs.org/angular/forms
- npm http GET https: //registry.npmjs.org/angular/core
- npm http GET https: //registry.npmjs.org/rimraf
- npm http GET https: //registry.npmjs.org/angular/router
- npm http GET https: //registry.npmjs.org/canonical-path
- npm http GET https: //registry.npmjs.org/types/jasmine
- npm http GET https: //registry.npmjs.org/angular/common
- npm http GET https: //registry.npmjs.org/rxjs
- npm http GET https: //registry.npmjs.org/systemjs
- npm http GET https: //registry.npmjs.org/zone.js
- npm http GET https: //registry.npmjs.org/angular-in-memory-web-api
- npm http GET https: //registry.npmjs.org/core-js
- npm http GET https: //registry.npmjs.org/lite-server
- npm http GET https: //registry.npmjs.org/karma
- npm http GET https: //registry.npmjs.org/concurrently
- npm http GET https: //registry.npmjs.org/karma-jasmine
- npm http GET https: //registry.npmjs.org/karma-chrome-launcher
- npm http GET https: //registry.npmjs.org/karma-cli
- npm http GET https: //registry.npmjs.org/typescript
- npm http GET https: //registry.npmjs.org/lodash
- npm http GET https: //registry.npmjs.org/jasmine-core
- npm http GET https: //registry.npmjs.org/karma-jasmine-html-reporter
- npm http GET https: //registry.npmjs.org/protractor
- npm http GET https: //registry.npmjs.org/tslint
- npm http GET https: //registry.npmjs.org/angular/platform-browser
- npm http GET https: //registry.npmjs.org/angular/platform-browser-dynamic
- npm http GET https: //registry.npmjs.org/angular/compiler
- npm http GET https: //registry.npmjs.org/angular/http
- npm http GET https: //registry.npmjs.org/types/node
- npm http GET https: //registry.npmjs.org/angular/router
- npm http GET https: //registry.npmjs.org/angular/core
- npm http GET https: //registry.npmjs.org/angular/forms
- npm http GET https: //registry.npmjs.org/canonical-path
- npm http GET https: //registry.npmjs.org/angular/common
- npm http GET https: //registry.npmjs.org/rimraf
- npm http GET https: //registry.npmjs.org/types/jasmine
- npm ERR!network tunneling socket could not be established, cause = connect ECONNREFUSED
- npm ERR!network This is most likely not a problem with npm itself
- npm ERR!network and is related to network connectivity.
- npm ERR!network In most cases you are behind a proxy or have bad network settings.
- npm ERR!network
- npm ERR!network If you are behind a proxy, please make sure that the
- npm ERR!network 'proxy'
- config is set properly.See: 'npm help config'
- npm ERR!System Windows_NT 6.2 .9200
- npm ERR!command "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Extensions\\Microsoft\\Web Tools\\External\\\\node\\node"
- "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Extensions\\Microsoft\\Web Tools\\External\\npm\\node_modules\\npm\\bin\\npm-cli.js"
- "install"
- npm ERR!cwd D: \Rahul\ PRACTICES\ Angular\ Angular2MVC\ Angular2MVC
- npm ERR!node - v v0 .10 .31
- npm ERR!npm - v 1.4 .9
- npm ERR!code ECONNRESET
- npm === = npm command completed with exit code 1 === =
Solution
To solve the above problem, you need to follow the below steps,
Step 1
Open command prompt of your system (run as administrator).
Step 2
In command prompt, type the below-highlighted command and enter,
C:\windows\system32>ping proxy
Step 3
You will find proxy URL of your work environment very similar to the below proxy URL format in the first line,
proxy.[company name].com
Note
Due to security purpose, I cannot show you the exact proxy URL of my work environment.
On pressing enter after writing above proxy command, you will get the output very similar to the about command window. You will get the proxy URL of your work environment in the first line.
Step 4
Now you need to set this proxy URL to your NPM config file using the command prompt. Run the below both commands one by one and enter (if the proxy doesn't need credentials),
- >npm config set https-proxy http://proxy.[Company Name].com:8080
- >npm config set https-proxy http://proxy.[Company Name].com:8080

In case proxy needs credentials, you need to pass credentials like below,
- >npm config set https-proxy http://<username>:<password>@proxy.[Company Name].com:[Port]
- >npm config set https-proxy http://<username>:<password>@proxy.[Company Name].com:[Port]
Step 5
Now you will be able to install any npm package just as below I am able to install TypeScript here,

Step 6
Once TypeScript is installed successfully, run the below command just to check which TypeScript version is installed,
>tsc –v
Note
To read more articles on Angular 2, please check out the below link,
Write me in comment box in case you have any questions or concerns. Have a great day!

Alex AlvesPosted May 15, 2020, 10:07 AM
Caraca, isso eh inacreditavel: funcionou!!! kkkkkkkk
Joseph JojoPosted Nov 29, 2019, 6:51 AM
Hi Rahul, this solution worked for me but after installing and creating angular project I'm getting another while setting up firebase in my project. I tried to run the command npm install firebase @angular/fire --save, and then im getting this error. npm ERR! Failed at the [email protected] install script.npm ERR! This is probably not a problem with npm. There is likely additional logging output above. Could you please help to fix this?
Miguel SirnaPosted Aug 5, 2019, 2:27 AM
Nada esto no funciona..
Gran TorinoPosted Feb 4, 2019, 1:16 AM
It worked, but then it suddenly became an error: failed, reason: write EPROTO 101057795:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:openssl\ssl\s23_clnt.c:827
karuna govindPosted Sep 18, 2018, 11:08 AM
I tried the above mentioned steps but i am still getting the error "npm WARN registry Unexpected warning for http://registry.npmjs.org/: Miscellaneous Warning ETIMEDOUT: request to http://registry.npmjs.org/@types/jasminewd2 failed, reason: connect ETIMEDOUT" I tried executing the above mentioned steps like this C:\Windows\System32>npm config set https-proxy http://proxy.yyy.zzz.net:8080. This is what i want to achieve - create a new app folder in angular 'ng new my-first-app'
Muhammad IqbalPosted Jul 31, 2018, 7:12 PM
Perfect article. Worked smoothly.
Francis CorbinPosted Mar 1, 2018, 12:06 PM
Thanks for that, but I'd like to try a different approach. I'm not keen on having to hard-code my password in the npm config. Next time my password changes, I'll have to remember to do it there or I'll get locked out. Instead, I'd like to ask our network security team to open the firewall to this specific traffic but I don't know what to ask for. Any idea?
Mrinal MahendraPosted Feb 1, 2018, 5:15 AM
Error while doing ping proxy : Ping request could not find host proxy. Please check the name and try again.
Helen AnitaPosted Jan 19, 2018, 2:14 AM
Hi Rahul, Nice article..I tried as said but it is saying like "The system cannot find the file specified." I tried with and without my corporate credentials.
Helen AnitaPosted Jan 19, 2018, 2:13 AM
Hi Rahul, Nice article..I tried as said but it is saying like "The system cannot find the file specified."
Sourabh SomaniPosted Oct 16, 2017, 3:30 AM
Good article :) But I think this article's category should be Node.js not angular. Because here you are downloading angular package so you are keeping it in angular but any package you will download you will get error.... Please update this category so it will be helpful for Node and Angular Both users