npm windows installation proxy issue - node.js

I am using below commands to setup proxy on window7
npm config set proxy http://<username>:<password>#<proxy-server-url>:<port>
npm config set https-proxy http://<username>:<password>#<proxy-server-url>:<port>
but I am not able to setup proxy correctly and when I am trying to run the command
npm config get proxy
I am getting erroneous proxy URL as below
http://<username>/:<password>#<proxy-server-url>:<port>
and
it seems slash before colon between "username:password" is getting added incorrectly as "username/:password".
How do I correctly configure npm proxy on windows?

write command in cmd(admin):
this work for me in w10
npm config set https-proxy http://username:password#proxy:port

Related

How to set npm config set proxy on npm start

Hi I'm trying to set a proxy every time I run a specific project with my npm run dev command.
I have something like https://www.npmjs.com/package/dotenv setting up my environment variables but I'm also looking to automating setting my
npm config set proxy http://proxy.example.com:1337
npm config set https-proxy https://proxy.example.com:1337
Does anyone have any solutions for this?
Note That I only want this for my development and note production.
For setting proxy and other configuration for npm just type the following command in the console
npm config edit
this command will open the .npmrc file, in that file set the proxy and other setting related npm
hope it will works.
npm config set proxy http://proxy.example.com:1337 will set the proxy for downloading the packages from npm repo.
when you run npm run dev, what is running is your app which is invoked by npm on node.js on your OS, so you need to set a proxy for your app or your OS.
System level proxy
Linux
https://askubuntu.com/questions/583797/how-to-set-a-proxy-for-terminal
Windows:
set http_proxy=socks5://127.0.0.1:1080
set https_proxy=socks5://127.0.0.1:1080
set ftp_proxy=socks5://127.0.0.1:1080
// unset
set http_proxy=
set https_proxy=
set ftp_proxy=
App level
I can't do anything about that.
Webpack dev server
I believe this is what you need, if you are using webpack dev server.
https://github.com/webpack/webpack-dev-server/blob/master/examples/general/proxy-simple/webpack.config.js

npm rollbackFailedOptional error when install any package

I have a problem when installing any npm packages. here is my error:
rollbackFailedOptional: verb npm-session xxxxxxxxxxx
for resolving this I do some stuff but I still get the same error.
I put registry=http://registry.npmjs.org/ in .npmrc file in my user folder and also run following commands:
npm config rm proxy
npm config rm https-proxy
I try to solve the problem in node 8.11.1 and node 10.1.0 and my npm version is 5.6.0.
Why this problem occurs and how can resolve that?
Update:
npm config list:
; cli configs
metrics-registry = "http://registry.npmjs.org/"
scope = ""
user-agent = "npm/5.6.0 node/v8.11.1 win32 x64"
; userconfig C:\Users\me\.npmrc
https-proxy = "https://username:password#proxy.company.com:6050/"
proxy = "http://username:password#proxy.company.com:6050/"
registry = "http://registry.npmjs.org/"
; builtin config undefined
prefix = "C:\\Users\\me\\AppData\\Roaming\\npm"
; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\Users\me
; HOME = C:\Users\me
; "npm config ls -l" to show all defaults.
Can you try enter this and then re run:
npm config set registry http://registry.npmjs.org/
I've tried almost all methods posted in various forums like stackoverflow, github-issues etc.. but nothing seemed to work.
Here are the commands I've executed in order which I encourage you to try because it worked for many people (but not me):
npm config rm proxy
npm config rm https-proxy
npm config set https-proxy https://username:password#proxy.company.com:6050
npm config set proxy http://username:password#proxy.company.com:6050
npm config set registry http://registry.npmjs.org/
And then when trying to install the package npm install -g express - it failed.
However, when I tried to run npm install npm#latest -g it miraculously executed and installed fine!
Then running npm install -g express again worked perfectly fine too.
TL;DR: updating npm to the latest version solved the issue (currently 6.0.1)
I am installing npm package behind corporate proxy. following steps resolved the issue for me -
Remove http and https proxy - npm config rm proxy and npm config rm https-proxy
Set registry - npm config set registry http://registry.npmjs.org/
Set http and https proxy - npm config set proxy yourCorporateProxyAddress:port ,
npm config set https-proxy yourCorporateProxyAddress:port
Install package - npm install packageName
I solved this problem by setting the proxy property of config.
The most likely reason you might be facing this problem is if you are behind a proxy.
You may follow the following steps to solve the issue
Type:
npm config get proxy
If you get null. It means the proxy is not set.
Go to Internet Explorer->Tools->Internet Options-> LAN Settings
Here you would find your proxy address and port under proxy server. If you have your username and password then do the following
npm config set proxy http://your-username:your-password#Proxy-address:port-number
After this you can use npm install.
I was getting same error in user command prompt then tried in PowerShell as an admin and it worked.
Run the following commands in Windows PowerShell as Administrator:
npm config set https-proxy https://username:password#proxy.company.com:6050
npm config set proxy http://username:password#proxy.company.com:6050
config set registry http://registry.npmjs.org/
I had resolved this identical issue by pointing the npm to the correct proxy when using a corporate machine. NO ADMIN REQUIRED!!!
Here are my steps:
Obtain the correct proxy by following these steps here! Copy/paste the proxy address into notepad. You will use this same proxy to set both the 'proxy' and 'proxy-https' params in the next step.
Execute the following 2 commands in your command window by replacing <contents> below with proxy address obtained in previous step:
npm config set proxy http://<proxy-server-url:port>
npm config set https-proxy http://<proxy-server-url:port>
NOTE: I ommitted 'username' and 'password' fields from the 'http://<username><password>#<proxy-server-url:port>' template which according to the source should work 9 out of 10 times, and worked perfectly for me.
Navigate to your project folder from the command line and execute 'npm install <package name(s)>'. The installation should be successfull.
first this
npm config rm proxy
npm config rm https-proxy
then this
npm config set registry https://registry.npmjs.org/
then Install package
npm install packageName
PS: be sure to check if your internet connection is correct.
I had the same issue!
Reinstalling the latest 32-bit nodejs worked for me.
Just to note, I don't have any proxy on my network. Sometimes, when I have this problem I reconnect to my wifi, which also works sometimes.
I had the same issue while trying to install from Github. The issues was because of bad usage of the scripts in package.json and their hooks.
I had same problem trying to install any npm package.
Solved by adding some proxy config
Go to Users->"yourUser"-> Open .npmrc with a text editor -> add those two lines
https-proxy=http://username:password#proxyUrl:port/
proxy=http://username:password#proxyUrl:port
Modify username and password, setting your user information.
Modify proxyUrl and port according to your needs
That worked for me!

NPM error install angular 2 CLI : tunneling socket could not be established, statusCode=405

When i installed angular 2 cli I get an error with the NPM :
Downloading binary from https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-48_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-48_binding.node":
tunneling socket could not be established, statusCode=405
Hint: If github.com is not accessible in your location
try setting a proxy via HTTP_PROXY, e.g.
export HTTP_PROXY=http://example.com:1234
or configure npm proxy via
npm config set proxy http://example.com:8080
node -v : 6.9.4,
npm -v :3.10.10
I don't use proxy. I have done few things like :
npm config rm proxy
npm config rm https-proxy
npm config set proxy false
npm cache clean
npm config set registry "https://registry.npmjs.org/"
but not working, I also have searched stackoverflow for few days, I don't get a solution, thank you..
HI I was facing the same issue and i did following configuration change.
Execute following commands in command prompt.
npm config set proxy null
npm config set https-proxy null
Hope it help you as well.

npm ERR! network getaddrinfo ENOTFOUND

I am getting npm ERR! network getaddrinfo ENOTFOUND error while trying to install any package using NPM. I know there are numerous threads on the same issue but I could not find any thread which can help me.
I have set the proxy & I think its something to do with proxy not being set correctly\not using the correct url.
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080
Is there any way to check the URL I am using while setting proxy is correct? Are there any steps I need to take in order rectify this issue?
Maybe it's because the proxy do not stand for https.
What I do is clear the proxy content of ~/.npmrc, or use
npm config delete proxy
What's more, nrm is recommended for this problem.
I was setting proxy as
npm config set http_proxy=http://domain:8080
instead of using the correct way
npm config set proxy http://domain:8080
Instead of setting the proxy usingnpm config set http_proxy=http://address:8080 go to ~/.npmrc and remove the proxy config. This resolved my issue.
I also faced this error but I was not working behind a proxy server at the moment so using npm config set proxy=http://address:8080 couldn't help and ~/.npmrc didn't contain any proxy setting either. The solution in my case was just to restart my computer.
I got the exact same error and this is what i did.
npm config get proxy
and it returned "null"
Opened "C:\Users\Myname.npmrc" in a notepad and made some changes. This is how my .npmrc file looks now
http-proxy=http://proxyhost/:proxyport
strict-ssl=false
registry=http://registry.npmjs.org/
The solution which worked for me:
Delete proxy: npm config delete proxy
Check npm config get proxy which should return null
Now, check if you are able to install the package. If not working, try manually editing the config, type: npm config edit, remember you are in VI editor.
Add ; before(for commenting out):
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080
Save and exit the file :x
Now, try installing the packages. It should work.
does your proxy require you to authenticate? because if it does, you might want you configure your proxy like this.
placeholder names.
username is a placeholder for your actual username.
password is a placeholder for your actual password.
proxy.company.com is a placeholder for your actualy proxy
*port" is your actualy port the proxy goes through. its usualy 8080
npm config set proxy "http://username:password#proxy.company.com:port"
npm config set https-proxy "http://username:password#proxy.company.com:port"
It happens due to proxy errors:
try this in cmd
npm config get proxy
if this is not null, then go to
c/users/computerName/.npmrc
open this in notepad
now clear the proxy line completely
try the above cmd
if it is null
then install angular
npm i -g #angular/cli
I had this issue in my Arch Linux distro with npm 14.3.0 (w/ npm 6.14.5). I simply deleted the ~/.npm directory and tried again and this time it worked.
For me removing the ~/Users/.npmrc from the folder helped.
I had incorrectly typed in the address as
http://addressOfProxy.8080
instead of
http://addressOfProxy:8080
(Notice the colon before the port number 8080.)
First I check whether proxy is set for me or not using this :
npm config get proxy
It returned null then I run this command
npm config set strict-ssl=false
It disable strict-ssl for that cmd session.
You can see complete list of config using this
npm config list ls -l
Step 1: Set the proxy
npm set proxy http://username:password#companyProxy:8080
npm set https-proxy http://username:password#companyProxy:8080
npm config set strict-ssl false -g
NOTES: No special characters in password except # allowed.
for some reason my error kept pointing to the "proxy" property in the config file. Which was misleading. During my troubleshooting I was trying different values for the proxy and https-proxy properties, but would only get the error stating to make sure the proxy config was set properly, and pointing to an older value.
Using, NPM CONFIG LS -L command lists all the properties and values in the config file. I was then able to see the value in question was matching the https-proxy, therefore using the https-proxy. So I changed the proxy (my company uses different ones) and then it worked. figured I would add this, as with these subtle confusing errors, every perspective on it helps.
Just unset the proxy host using :
unset HOST
This worked for me.
Make sure to use the latest npm version while installing packages using npm.
While installing JavaScript, mention the latest version of NodeJS. For example, while installing JavaScript using devtools, use the below code:
devtools i --javascript nodejs:10.15.1
This will download and install the mentioned NodeJS version. Try installing the packages with npm after updating the version. This worked for me.
Take a look at your HTTP_PROXY and HTTPS_PROXY environment variables.
I thought mine were set correctly, as http://username:password#proxyhost:proxyport, but it turned out that they were actually causing the problem! After deleting those variables, and restarting the commant prompt, the npm commands worked again.
Well, everybody giving their answer so I thought I write too.
I am having the same proxy issue as all others. To solve this I tried many solutions but it did not work.
Search .npmrc file name in C:\Users\your_username drive and than add this line:
http://proxy.company.com:8888
I did only this and my is solved.
Step 1: Check whether proxy is set for you or not
npm config get proxy
Step 2: If it returned null and you also don't want any proxy, go to ~/Users/.npmrc
Open the file and make sure it has the following written:
registry=http://registry.npmjs.org/
Disable strict-ssl for cmd session
npm config set strict-ssl=false
Try to npm install now
P.S Now if get proxy didn't return null check if the proxy is correct or else set it with
npm config set proxy http://proxy.example.com:6500
in my case, the error was I wasn't being consistent in usage of package manager, previously I installed my all packages with yarn and now I was using npm to install moment-timezone package and was facing this error, when I tried to install the package with yarn it was done successfully with command yarn add moment-timezone
Had the same issue but non of the above help then I tried this:
ipconfig /flushdns
ipconfig /renew
After that everything worked as expected.
I hope it helps you guys
The solution which worked for me:
Delete proxy: npm config delete proxy. Also npm config delete https-proxy
Check
npm config get proxy
npm config get https-proxy
This should return null
Now, check if you are able to install the package.
I use WSL with Ubuntu distro. Had the same issue and none of the above solutions worked.
Ran the following command, then everything started working,
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf > /dev/null
For me, my wifi network settings had DNS set to 8.8.8.8 I just removed that and ran npm i again and it worked!
go to the directory C:\Users\username and delete the npmrc file
this solved my issue
I was having some proxy configuration in my {$HOME}/.npmrc file.
Clearing it helped.
If your proxy config is fine, sometimes the problem can be a deprecated package-lock.json file, therefore it redirects to a non-existing artifactory, npm registry.
Try to delete the package-lock.json and try npm i again.
strict-ssl=false
proxy = http://ip_address_of_proxy:8088
https-proxy = https://ip_address_of_proxy:8088
registry = http://registry.npmjs.org/
This solution worked for me:
npm set https-proxy http://username:Password#proxyhost/:proxyport
npm config set strict-ssl false -g
Try to install now (e.g. npm i tailwind -g)

How to clear https proxy setting of NPM?

How can I clear the previous ssl proxy setting of NPM?
well, I search a lot, but all post I got is mainly about how to set proxy in corporate network.
I try to set proxy to nothing:
npm config set http-proxy
npm config set https-proxy
the first command pass yet the second one warn that:
npm WARN invalid config proxy=""
npm WARN invalid config Must be a full url with 'http://'
is the warning neglectable and I have successfully clear the proxy setting?
None of the above helped me, but this did:
npm config rm proxy
npm config rm https-proxy
Source: http://jonathanblog2000.blogspot.ch/2013/11/set-and-reset-proxy-for-git-and-npm.html
Try deleting them with:
npm config delete proxy
npm config delete https-proxy
npm config rm proxy
npm config rm https-proxy
unset HTTP_PROXY
unset HTTPS_PROXY
unset http_proxy
unset https_proxy
Damn finally this does the trick in Debian Jessie with privoxy (ad remover) installed, Thank you :-)
This was already answered but I think the --global config is not covered properly.
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.
So at the end this will clean-up proxies from both local and global configs:
npm config rm proxy
npm config rm https-proxy
npm config --global rm proxy
npm config --global rm https-proxy
In the latest version npm rm proxy does not work. Instead use npm rm http-proxy
npm config rm proxy
npm config rm https-proxy
By the default value npm is looking for packages from https://registry.npmjs.org. What you also need to do is override the registry and strict-ssl values.
npm config set registry "http://registry.npmjs.org"
npm config set strict-ssl false
If you go through the npm config documentation, it says:
proxy
Default: HTTP_PROXY or http_proxy environment variable, or
null
Type: url
As per this, to disable usage of proxy, proxy setting must be set to null. To set proxy value to null, one has to make sure that HTTP_PROXY or http_proxy environment variable is not set. So unset these environment variables and make sure that npm config ls -l shows proxy = null.
Also, it is important to note that:
Deleting http_proxy and https_proxy config settings alone will not
help if you still have HTTP_PROXY or http_proxy environment variable
is set to something and
Setting registry to use http:// and setting
strict-ssl to false will not help you if you are not behind a proxy
anyway and have HTTP_PROXY set to something.
It would have been better if npm had made the type of proxy setting to boolean to switch on/off the proxy usage. Or, they can introduce a new setting of sort use_proxy of type boolean.
I have used the below commands for removing any proxy set:
npm config rm proxy
npm config rm https-proxy
And it solved my problem :)
there is a simple way of deleting or removing the npm proxies.
npm config delete proxy
npm config delete https-proxy
I had the same problem once.
Follow these steps to delete proxy values:
1.To delete proxy in npm:
(-g is Important)
npm config delete proxy -g
npm config delete http-proxy -g
npm config delete https-proxy -g
Check the npm config file using:
npm config list
2.To delete system proxy:
set HTTP_PROXY=null
set HTTPS_PROXY=null
Now close the command line and open it to refresh the variables(proxy).
Nothing above worked for me. I had to edit the file ".npmrc" which will be under user home directory (ex: c:\users\abcuser) :
http_proxy=null
registry=https://registry.npmjs.org/
strict-ssl=true
proxy=null
This works
npm config delete http-proxy
npm config delete https-proxy
npm config rm proxy
npm config rm https-proxy
set HTTP_PROXY=null
set HTTPS_PROXY=null
Running npm version 2.10.1 in windows 7, I used:
npm config delete proxy
npm config delete https-proxy
Try This,
npm config delete http-proxy
npm config delete https-proxy
npm config rm proxy
npm config rm https-proxy
set HTTP_PROXY=null
set HTTPS_PROXY=null
The easiest way to remove any configuration at all from npm is to edit the npm config file. It only takes two(2) commands to do this; one to open npm config file for editing, the other to confirm your change.
type npm config list to view a list of all npm configurations that are active.
type npm config edit to open a text editor with npm configurations.
To remove the proxy line ( or simply comment it out ).
Save the config file and close it.
type npm config list to confirm that the proxy configuration has been removed.
C'est la vie!
I tried everything listed on this page, none worked, then I tried to the config edit. It worked instantly. (I use Windows 10)
npm config delete proxy -g
worked for me.
-g was important as initially it was set with that option.
You can check configurations set with :
npm config list
npm config rm proxy
npm config rm https-proxy
Worked for me
I think it's not http-proxy but proxy:
npm config set proxy="http://yourproxyhere"
Got exactly the same problem, I keep seeing my proxy configuration even after removing the npmrc file and deleting the keys.
I found out that npm were using windows env key http-proxy by default.
So go in Computer->Properties->Advanced system settings->Environement variables and check there is no http-proxy key configured.
In my case (Linux Mint 16 based on Ubuntu), I had to:
npm config delete https-proxy, and also
clear the https_proxy Bash environment parameter — oddly enough, although I cannot find this behavior documented anywhere, npm fallbacks to https_proxy:
$ http_proxy='' https_proxy='' npm config get https-proxy
null
$ http_proxy='' xxhttps_proxy='' npm config get https-proxy
https://1.2.3.4:8080
See the npm Settings in file C:\Users\myusers.npmrc file. Sometime the npm proxy config settings does not apply. so its worth checking in there.
npm config delete http-proxy
npm config delete https-proxy
npm config delete proxy -g
npm config delete http-proxy -g
then
npm config get proxy
null
also
npm i -g bower to update
npm had a bug on the proxy
If you want to switch between proxy for company network and remove proxy for home/personal network you can use --no-proxy
Sample usage:
npm install --save-dev "#angular/animations#8.2.14" --no-proxy
execute npm config list
it will list down all proxy values.. in my case proxy value was fetched form global npmrc file, removed it and was able to complete npm install on my windows machine
Well, I'm gonna leave this here because I was having a big trouble with NPM.
I was trying to change a proxy setting using npm config set proxy "http://.../" and then running npm config get proxy. It was ALWAYS returning a wrong value, different from the one that I'd set.
I found out that I had a .npmrc COMMITED on the project I was trying to run npm install and that this file was overriding my own config.
So it was cleaning the proxy value, but I needed to also change the .npmrc inside the folder's project.
After that, everything worked fine.
I've used
npm config set proxy null
npm config set https-proxy null
and it worked for me.
Best regards
this works for me fime
proxy=http://<username>:<pass>#proxyhost:<port>
https-proxy=http://<uname>:<pass>#proxyhost:<port>
sample in my instance username:uname and password:pword
npm config set proxy=http://uname:pword#192.168.5.8:8080
npm config set https-proxy=http://uname:pword#192.168.5.8:8080
I was struggling with this for ages. What I finally did was go into the .npmrc file (which can be found in the user's directory followed by the user's name, ie. C:\Users\erikj/.npmrc), opened it with a text editor, manually removed any proxy settings and changed the http:// setting to https://. In this case, it is a matter of experimenting whether http or https will work for you. In my case, https worked. Go figure.
In my case, (windows OS), after put all those commands listed, npm kept taking
the proxy in the setting of windows registry
\ HKEY_CURRENT_USER \ Environment
just remove the proxy settings there, after that, I restarted the pc and then "npm install" worked for me
Example
Http Module is deprecated and it is replaced with HttpClient.
Change your imports to import { HttpClientModule } from '#angular/common/http';

Resources