Yarn install hang but npm works with the same config - npm

When I try to do a yarn install, it hangs. With npm all works fine.
My .npmrc file:
strict-ssl=false
registry=https://[url]/artifacts/repo/npm/
My .yarnrc file:
strict-ssl false
registry "https://[url]/artifacts/repo/npm/"
yarn --verbose output:
verbose 2.703 Performing "GET" request to "[url]/repo/npm/#company/coco.tools-nodejs-lite/-/#company/coco.tools-nodejs-lite-1.0.1.tgz".
[###---] 3/6
I have a private ssl registry and I've seen that when I do a npm install all packages are download from https url, but when I do a yarn install, the packages are download from http. If I delete strict-ssl false in Yarn doesn't work either. If I delete strict-ssl=false in npm I obtain this error:
...tgz failed, reason: unable to verify the first certificate
The registry doesn't work with http request, it only works with https, and when I try to access the registry by browser I obtain a SEC_ERROR_UNKNOWN_ISSUER, but I think that this isn't the problem. The problem is that Yarn's requests are done to http instead https but if I put strict-ssl=true and request are done to https Yarn hangs too...
Can anyone help me?

Related

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

Cannot login into Verdaccio

I have just installed Verdaccio on my computer. I have changed nothing in the config file, apart from adding proxy_related info:
http_proxy: http://proxy.ip:8080
https_proxy: https://proxy.ip:8080
no_proxy: localhost,127.0.0.1
After starting the process, I have tried to login to the registry from the library project workspace
npm adduser --registry http://localhost:4873
But I get this error:
npm ERR! 503 Service Unavailable - POST http://localhost:4873/-/v1/login
If I try to reach http://localhost:4873/ from my browser, I can see the Verdaccio webpage.
What am I doing wrong?
I don't know what kind of environment you are trying this (work, home, etc.) but, for me, my problem was that behind a corporate firewall I have to configure the NPM proxy (http and https), so adding the localhost as an exception to noproxy config attribute of NPM, it worked for me.
npm config set noproxy localhost
Try to change yours, from no_proxy to noproxy, maybe it is simple as that.

Errors setting npm proxy config

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.

How to fix timeout for packages on `npm install`?

When I run npm install it seems to work fine until part way installing packages. It seems to have no problem with the first half, but then after a while it will fail to be able to reach other packages. I just get the repeating errors, eg:
npm http request GET https://registry.npmjs.org/react-hot-loader
npm info attempt registry request try #3 at 6:43:34 AM
npm http request GET https://registry.npmjs.org/react-tap-event-plugin
npm info attempt registry request try #3 at 6:43:34 AM
npm http request GET https://registry.npmjs.org/react-test-renderer
etc.
It will continue to do this for an hour and and then the install will fail.
The install breaks at a different package each time so I don't think it's a problem with a particular file.
I can access these files fine with my browser and curl.
My work has a firewall but this domain is whitelisted.
Would anyone know what I could do to get this to work or what could be causing it?
If it's about the timing problem you should find a speed solutions for npm install.
So you can try these faster command than npm install :
pnpm install %70 faster
or
npm install --no-audit 15% faster
or
npm install --prefer-offline --no-audit 15% faster
check this article for details : speeding up npm install
You can override the max and min timeout in ~/.npmrc.
// npm config ls -l
// add these 2 lines in ~/.npmrc
fetch-retry-maxtimeout = 6000000
fetch-retry-mintimeout = 1000000
If your internet connection is the problem, try increasing the timeout:
npm config set timeout 6000000
The value is a 32-bit int.
If it's still relevant or maybe for other people of interest: For me it helped, deleting the package.lock file and running npm cache clean --force.
It might not be your case, but I had issues with a package being hosted at github with the repo url being only with git protocol (port 9418 not usually open on firewall).
Once added that to the firewall I could npm install without issues.
You can view the repository url with:
$ npm view zone.js repository.url
git://github.com/angular/angular.git
I saw an answer earlier that can resolve your problem by overriding the max and min timeout in ~/.npmrc file, but some didn't understand how to do it.
First go to the nodejs folder - for me it's located at ( Y:\Program Files\nodejs )
Open the node_modules folder.
Then npm folder.
Select (.npmrc) file + right click and open it with any text editor you want.
Finally add these 2 lines and click Ctrl+S
fetch-retry-maxtimeout = 6000000
fetch-retry-mintimeout = 1000000
.npmrc file after modification
npm cache clean --force
npm install --force
It works fine.
If you are on windows, try running vscode as administrator, it worked for me, I tried npm config delete https-proxy , npm config delete proxy and , tried deleting node_modules, and package.lock.json and ran npm cache clean --force but at last ran vscode as adminitrator before deleting node_modules and package.lock.json, it worked
I solved the timeout issue by executing these commands:
rm package-lock.json
npm i

Can't run bower or npm through network firewall even with proxy set - ETIMEOUT

I can't get bower or npm to work though a client's network and I'm not sure if I'm setting up the proxy settings correctly.
I've tried the various suggestions on answers to similar questions and simply nothing works for me. I get the following error:
C:\myproj>bower search react
bower retry Request to http://bower.herokuapp.com/packages/search/react
failed with ETIMEDOUT, retrying in 1.7s
bower retry Request to http://bower.herokuapp.com/packages/search/react
failed with ETIMEDOUT, retrying in 3.6s
bower retry Request to http://bower.herokuapp.com/packages/search/react
failed with ETIMEDOUT, retrying in 7.0s
bower retry Request to http://bower.herokuapp.com/packages/search/react
failed with ETIMEDOUT, retrying in 14.6s
I can access http://bower.herokuapp.com fine though the browser and it serves me the json reply.
my .bowerrc file (used '\\' on the domain\user name as it failed to parse it otherwise):
{
"directory": "Content/bower_components",
"proxy": "http://mydomain\\myuser:mypassword#nnnnn004.claims.local:8080",
"https-proxy": "http://mydomain\\myuser:mypassword#nnnnn004.claims.local:8080",
"strict-ssl": false,
"registry": "http://bower.herokuapp.com"
}
for NPM it just hangs:
C:\myproj>npm install grunt-cli
npm WARN package.json cl.clientappointment#1.0.0 No repository field.
npm WARN package.json cl.clientappointment#1.0.0 No README data
|
my .gitconfig file:
[url "http://"]
insteadOf = git://
[http]
proxy = http://mydomain\\myuser:mypassword#nnnnn004.claims.local:8080
[https]
proxy = http://mydomain\\myuser:mypassword#nnnnn004.claims.local:8080
my .npmrc file:
proxy=http://mydomain\\myuser:mypassword#nnnnn004.claims.local:8080/
https-proxy=http://mydomain\\myuser:mypassword#nnnnn004.claims.local:8080/
strict-ssl=false
All works fine if I connect to a different network without firewall.
I'm not sure if I've entered my user name/ password correctly on the proxy string supplied, or if I'm just missing a setting somewhere else.
So the problem was that I didn't escape special characters in my proxy url used by NPM (.npmrc) and Bower (.bowerrc).
i.e.
proxy=http://domain\user:password#proxy:8080"
needed to be
proxy=http://domain%5Cuser:password#proxy:8080"