Node NPM proxy authentication - how do I configure it?
Asked Answered
S

5

26

I'm new to Node and trying to install TypeScript using the following command:

npm install -g typescript

I get the following error:

if you are behind a proxy, please make sure that the 'proxy' config is set properly.

I have set my proxy using the following commands:

npm config set proxy http://Username:Pa55w0rd@proxyhostname
npm config set https-proxy http://Username:Pa55w0rd@proxyhostname

and tried this also:

npm config set proxy http://"ninjadev:5trongP@ssw0rd"@proxy.some-bigcorp.com
npm config set https-proxy http://"ninjadev:5trongP@ssw0rd"@proxy.some-bigcorp.com

But none of them work. I am working behind a copmpany proxy with authentication, so I think this is stopping me from connecting. I have added my username and password and this also didn't work.

Does anyone have any idea how I can connect to npm whilst using the company proxy and authentication?

Thanks

Sikkim answered 21/10, 2016 at 8:35 Comment(2)
use this solution. it worked for me.Infest
Be sure to URL encode @ in passwords as %40. Otherwise it will probably think ninjadev:5trongP is the user/pass and ssw0rd"@proxy.some-bigcorp.com (or something similar) will be the host.Harner
C
39

Did you try with

npm config set proxy http://"ninjadev:5trongP@ssw0rd"@proxy.some-bigcorp.com:PORT
npm config set https-proxy http://"ninjadev:5trongP@ssw0rd"@proxy.some-bigcorp.com:PORT

where PORT can be 8080 if you don't have the proxy port?

Circumlunar answered 14/2, 2017 at 14:33 Comment(2)
Note that password containing @ cannot be parsed.Bebop
@FaizanMubasher for passwords with an @ or other meaningful special characters, replace them by their encodeURIComponent versions. For example, @ becomes %40.Nunnery
O
15

This worked for me:

npm config set https-proxy "ninjadev:5trongP@ssw0rd"@proxy.some-bigcorp.com:PORT

Whithout http/https before.

Other answered 2/8, 2017 at 14:25 Comment(1)
worked for me too, should be marked as the answer, nicedone @OtherEmarie
S
3

The following code worked for me:

npm config set proxy "http://"username:password"@proxy.big-corp.com"

Samaveda answered 22/11, 2017 at 14:11 Comment(0)
S
1

This thing worked for me:

npm config set proxy http://"ninjadev:5trongP@ssw0rd"@proxy.some-bigcorp.com:PORT

Open cmd as an administrator and past the command there. Modify the command with credentials provided for your user.

Spheroidicity answered 10/6, 2018 at 7:6 Comment(0)
R
0

In ubuntu-18.04 make sure that in home directory .npmrc file contains:

proxy=http://username:password@proxyhostname:port

https-proxy=http://username:password@proxyhostname:port
Ridinger answered 21/1, 2019 at 11:19 Comment(1)
From Review: Hi, this post does not seem to provide a quality answer to the question. Please either edit your answer and improve it, or just post it as a comment.Halvah

© 2022 - 2024 — McMap. All rights reserved.