Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm proxy settings escape '\' char

I am behind a corporate proxy and I need to set the settings to npm. The only problem is my username contains a \ char. The proxy setting should look like this: http://PREFIX\username:[email protected]:port but the end result is like this: http://prefix/username:[email protected]:port which is totally wrong.

Putting %5C instead of \ doesn't work. Neither does putting the username and password, or the whole url in "".

I know this question has been asked numerous times but none of the solutions did it for me. I am on a windows machine. I would be grateful if you have any suggestions.

like image 564
I.Anchev Avatar asked Jan 11 '16 11:01

I.Anchev


People also ask

How do you escape special characters in proxy?

You may get the error due to special characters. The solution is to use unicode characters in hexadecimal. You can use command line tool such as unum or gnome-character-map to convert special characters into hexadecimal unicode.

How do I remove HTTP proxy from npm config?

By running npm config rm proxy you remove proxy from user configuration. This can be easily verified by running: npm config list. If there is proxy or https-proxy setting set in global config you have to use --global in the command to remove it.


2 Answers

You have to percent-encode | encode the special characters. E.g. instead of this:

http://foo:B/[email protected]:8080

you write this:

http://foo:B%[email protected]:8080

So / gets replaced with %2F.

like image 131
TheCodeGladiator Avatar answered Oct 16 '22 04:10

TheCodeGladiator


Use %5C, it will replace '\'

http://foo:T\[email protected]:8080

to

http://foo:T%[email protected]:8080
like image 20
Lucas Zamecki Avatar answered Oct 16 '22 04:10

Lucas Zamecki