Errors setting npm proxy config - npm

I tried various npm config but all failed:
registry=http://registry.npmjs.org/
proxy=http://host:8080/
https-proxy=http://host:8080/
strict-ssl=false
This failed with 418 I'm a teapot error.
registry=https://registry.npmjs.org/
proxy=http://host:8080/
https-proxy=http://host:8080/
strict-ssl=false
This just failed to connect.(ECONNRESET)
registry=https://registry.npmjs.org/
proxy=http://host:8080/
https-proxy=https://host:8080/
strict-ssl=false
Finally this failed with:
write EPROTO 140588447455040:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:252:
How should I set config to install packages through proxy server?
npm version : 6.4.1
OS : ubuntu 18.0.4

I ran into the same issue trying to install gulp.
There is something weird about proxy configuration in npm. It appears that old versions of the proxy & https-proxy settings persist somehow, even if they're not in the config. For me, an old proxy setting, with a previous, expired, password was still present, even after I tried deleting via "npm config delete proxy".
What worked for me was to use
npm config edit
then add in valid entries for proxy and https-proxy. e.g.
proxy=http://[username]:[password]#[proxyhost]:8080/
https-proxy=http://[username]:[password]#[proxyhost]:8080/
It seemed that the https-proxy line was the one that got it working.

Related

I can’t show the version of an NPM package (nodemon --version), what to do?

I tried to run codes in my hyper-terminal (deleted nodemon and then reinstalled it) but at the end I still can NOT get the version of my nodemon, it says:
"C:\Users\azadk\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found"
Here’s what I tried to do:
I also tried to set the path of Environment variables to "C:\Program Files\nodejs" but still I can’t get the version.
If you are connected to some sort of VPN or your corporate internet, try to connect to another network and run the call again.
I entered these commands and the problem was resolved:
npm config rm proxy
npm config rm https-proxy
npm config delete http-proxy
npm config delete https-proxy
set HTTP_PROXY=null
set HTTPS_PROXY=null

Cannot load a package using NPM - local certificate error

Apologies if this is a repeat question, but I am new to this. I have installed nodeJS and am trying to install hardhat. I have a Windows 10 laptop.
I followed the instructions here: https://hardhat.org/tutorial/setting-up-the-environment
I am trying to run the following code:
mkdir hardhat-tutorial
cd hardhat-tutorial
npm init --yes
npm install --save-dev hardhat
Then I get the following errors:
npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY
npm ERR! errno UNABLE_TO_GET_ISSUER_CERT_LOCALLY
npm ERR! request to https://registry.npmjs.org/hardhat failed, reason: unable to get local issuer certificate
When I search this online it says to try the following solutions:
npm config set strict-ssl false
OR
npm config set registry http://registry.npmjs.org/
I've done both and rebooted the PC and it doesn't make a difference. Anyone got any ideas of what I can do to resolve this?
Thanks
John
You are running from behind a "deep inspection" web proxy, which issues fake SSL certificates to allow it to inspect your traffic, and although there are probably automated systems to make your browser trust the root CA cert that issues these certificates, npm is not configured to trust that CA.
You should be able to get the CA cert from your browser, the system keychain, or your IT department, and then configure npm to use it with npm config set cafile /path/to/cert.pem
even if you don't know where the corporate certificate is located you can solve it for a single terminal use by running set NODE_TLS_REJECT_UNAUTHORIZED=0 before running the npm commands it will work for the current terminal session.
or you can run setX NODE_TLS_REJECT_UNAUTHORIZED 0 /m once
beware this option as security risks!
to cancel this setting you should run REG delete "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /F /V NODE_TLS_REJECT_UNAUTHORIZED .
the best way to solve the problem will be to find the corporate certificate and run the following command SetX NODE_EXTRA_CA_CERTS "path/to/certificate" /m when you change path/to/certificate by the full path.
Turning off strict ssl: npm config set strict-ssl=false
Changing the registry to http instead of https: npm config set registry http://registry.npmjs.org/
Changing my cafile setting: npm config set cafile /path/to/your/cert.pem
Stop rejecting unknown CAs: set NODE_TLS_REJECT_UNAUTHORIZED=0

How to install files using npm behind proxy?

While running the npm install command, I'm getting:
ERR 418 I m a teapot
I set a proxy but I'm not sure whether it is correctly parsed. I doubt that the proxy might be the reason. Can someone help me on this? I also ran npm config get proxy.
Try something like this:
npm config set proxy 213.169.158.34:8080
npm config set https-proxy 213.169.158.34:443
npm config set registry http://registry.npmjs.org/
npm instal

Cannot install node-sass

I'm in an environment where I am required to run a local proxy, and I am unable to install node-sass. When I try the following:
npm install -g node-sass
I get an error:
Cannot download "https://github.com/sass/node-sass/releases/download/v4.5.3/win32-x64-48_binding.node": tunneling socket could not be established, cause=read ECONNRESET
I have already installed cntlm and configured it correctly. To verify I use the porxy server to access internet and it works fine.
The following environment variables are set
http_proxy -> http://localhost:3128
https_proxy -> http://localhost:3128
Have also added the following to my .npmrc
https-proxy=http://localhost:3128
http-proxy=http://localhost:3128
proxy=http://localhost:3128
Also tried by adding slashes to the end but the result is the same.
Any clues and help would be appreciated since I have no idea how to resolve this.
Additional details:
node -v
v6.11.4
npm -v
5.5.1
The workaround I found was to download the node-sass file from https://github.com/sass/node-sass/releases/download/v4.5.3/win32-x64-48_binding.node and then set the sass-path to the binaries downloaded:
SET_SASS_BINARY_PATH = C:\..\..\
and then doing
npm install -g node-sass
worked for me.

manually install npm packages?

I'm experimenting with protractor and following tuturial on github. NPM was already present on my system, I succesfully downloaded protractor and now I'm proceeding with
webdriver-manager update
Which fails with
downloading http://selenium-release.storage.googleapis.com/2.42/selenium-server-standalone-2.42.2.jar...
Error: Got error Error: getaddrinfo ENOTFOUND from http://selenium-release.storage.googleapis.com/2.42/selenium-server-standalone-2.42.2.jar
Updating chromedriver
Error: Got error Error: getaddrinfo ENOTFOUND from https://chromedriver.storage.googleapis.com/2.10/chromedriver_win32.zip
downloading https://chromedriver.storage.googleapis.com/2.10/chromedriver_win32.zip...
Per earlier answered equal questions I double checked my npm proxy settings, all fine for http and https. Also I can see the username:password#proxy definition in .npmrc in my userprofile directory (c:/Users/my-name), the files are also present on the internet. Also the npm install action of protractor worked well. Now is it possible to manually (via browser download the relevant files and have them exploded and installed in the designated places?
I'm on windows 7 SP 1, 32 bit.
Yes you can manually install the webdriver-manager file in "node_modules\protractor\bin".
By the way , the error message really looks like you have a trouble to access internet.
Did you try to set these variables before launching your npm command:
set HTTP_PROXY=http://'your http proxy ip':'your proxy port'
set HTTPS_PROXY=http://'your https proxy ip':'your proxy port'
To answer my own question:
As Yannick mentioned: I only set the proxy configuration with npm config ... For this you also need to set the environment variables
set PROXY=http://<username>:<password>#proxyserver
set HTTP_PROXY=%PROXY%
set HTTPS_PROXY=%PROXY%