request to https://registry.npmjs.org/co failed
Asked Answered
K

13

23

If I do npm install in my repository. I get the below error

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/co failed, reason: unable to get local issuer certificate

I tried with

npm config set registry https://registry.npmjs.org/

But it does not solve the problem

Please help to resolve this issue. Thanks in advance!

Kufic answered 9/2, 2019 at 23:6 Comment(6)
You can do this npm config set strict-ssl false. But it is not safe to do safe. You should only try if you cannot find a fix for it. I recommend you uninstall everything and then re-install itMarcelline
@Marcelline Do you want me to reinstall npm ?Kufic
I mean uninstall your nodejs and then reinstall it. It happened to me before. After I re-install node, everything works just fine. I am not sure it will work for you but you should give a tryMarcelline
Read this npm.community/t/common-proxy-and-networking-problems/151 if it does not workMarcelline
@Marcelline I reinstalled nodejs and did npm config set strict-ssl false. but didnot solve the problem. Still i get error. please see the error message in my comment below gyp WARN install got an error, rolling back install gyp ERR! configure error gyp ERR! stack Error: unable to get local issuer certificate gyp ERR! stack at TLSSocket.<anonymous> (_tls_wrap.js:1116:38) gyp ERR! stack at emitNone (events.js:106:13) gyp ERR! stack at TLSSocket.emit (events.js:208:7)Kufic
I just realized that the OS time and date are not up to date, So checking the automatic update in date settings solved the problem.Saintjust
S
35

This appears to be an issue with attempting to use SSL while installing your project's required packages. This occurs due to how you set your npm registry:

npm config set registry https://registry.npmjs.org/

Notice the https prefix in your npm registry, Hyper Text Transfer Protocol Secure (HTTPS) is the secure version of HTTP, the protocol over which data is sent between your browser and the website that you are connected to. The 'S' at the end of HTTPS stands for 'Secure'. It means all communications between your browser and the website are encrypted. HTTPS pages typically use one of two secure protocols to encrypt communications - SSL (Secure Sockets Layer) or TLS (Transport Layer Security).

Perhaps you can try the following to see if it resolves your issue:

npm config set registry http://registry.npmjs.org/  

Then try reinstalling your dependencies with an npm install

Alternatively, you can turn off the ssl requirement (although use at your own discretion) by doing the following:

npm config set strict-ssl false

then try to install your requirements again with an npm install

Sulky answered 9/2, 2019 at 23:35 Comment(3)
I reinstalled nodejs and did 'npm config set registry registry.npmjs.org' and npm config set strict-ssl false but still i get the below error message. gyp WARN install got an error, rolling back install gyp ERR! configure error gyp ERR! stack Error: unable to get local issuer certificate gyp ERR! stack at TLSSocket.<anonymous> (_tls_wrap.js:1116:38) gyp ERR! stack at emitNone (events.js:106:13) gyp ERR! stack at TLSSocket.emit (events.js:208:7)Kufic
If you're on a WIN environment check out this link: github.com/nodejs/help/issues/979. They had to do the following: $ sudo npm install -g node-gyp $ node-gyp configure and then reinstalling the libraries with an npm install workedSulky
I get this when I try to do npm install after setting it to http: npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher. You are currently using plaintext http to connect. Please visit the GitHub blog for more information: h ttps://github.blog/2021-08-23-npm-registry-deprecating-tls-1-0-tls-1-1/Environs
C
8

Removing package-lock.json file (and restarting build) solved this issue for me.

Chauncey answered 28/7, 2020 at 19:21 Comment(0)
E
6

This is probably due to a proxy network. You can disable the proxy and run npm install
Or make sure you set the proxy configurations

npm config set https-proxy [address]:[port]

Then try npm install again

Eureetloir answered 5/4, 2022 at 19:14 Comment(0)
P
5

I just had the same issue (just learning NodeJS for the first time). Turned out that I had a ZScaler issue. I disabled it for the download and it worked.

Padriac answered 8/6, 2020 at 17:1 Comment(1)
Oh man this suggestion just saved me!! Thank you! Even just browsing to registry.npmjs.org would give me the ERR_CONNECTION in Edge, Firefox and Chrome. I too had ZScaler running. Turned it off and the site magically resolved.Miscall
W
2

Our company VPN was causing this conflict. I disabled the VPN. Dave Girvitz tip about Zscaler led me to investigate the VPN.

Weever answered 2/8, 2022 at 1:48 Comment(2)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Virtuous
how did u resolve it?Theatrician
B
1

change registry url if it is http from below command

npm config get registry http://registry.npmjs.org

and also disable ipv6 ipv6 connectivity by going to the control panel.

Bianca answered 26/11, 2023 at 7:17 Comment(0)
T
0

Make sure that you can reach the link: http://registry.npmjs.org/ or https://registry.npmjs.org/ then set registry as needed: npm config set registry http://registry.npmjs.org/

You night need to set it in your HOSTS file if it's not resolved. If all is well so far, and after the changes by @nathan above seems not to work, i suggest restarting the networking with:

sudo service network-manager restart
sudo service docker restart

then run you run npm build script again.

Thebault answered 6/9, 2021 at 13:46 Comment(0)
D
0

I switched to cloudfare's DNS. Now, things are working fine. You can use this

Dangle answered 8/9, 2021 at 9:31 Comment(0)
S
0

Video Reference Youtube=> https://youtu.be/vzORm7AUUSQ

I have changed registry url from http to https like below , also cleaned the cache, removed proxy but nothing work.

npm config get registry https://registry.npmjs.org

The only things that work for me is disabling ipv6 connectivity by going to the control panel

Slideaction answered 16/10, 2023 at 10:21 Comment(0)
P
0

This post gave me the answer I need!

# Windows/MacOS/Linux 
npm config set cafile "<path/to/your/certificatefile.crt>"

# Check the 'cafile'
npm config get cafile

After running the snippet above ("<path/to/your/certificatefile.crt>" <- this is your full path to your certificate file) my npm install worked like charm!

On the other hand, the script below did NOT work for me:

npm config set https-proxy [address]:[port]

Error: (unable to get local issuer certificate): enter image description here

And the other answers seems rather insecure (the certificates are for a reason, right?).

So I hope after the first script provide you are able to run npm install with no errors :)

Potiche answered 23/4 at 10:39 Comment(0)
S
0

I was getting this error on Mac only but not a PC. I wasted hours trying to solve. In the end I removed docker desktop and installed Rancher. It worked immediately, I removed all my workarounds and it still worked. I wished I'd known about this earlier as it would have saved days worth of pain.

https://docs.rancherdesktop.io

Scamp answered 11/5 at 22:3 Comment(0)
J
-3

Disable your antivirus and try to install. It worked for me.

Janetjaneta answered 10/1, 2023 at 5:54 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Virtuous
D
-5

Connect to faster internet in order to install packages.

Doctorate answered 25/12, 2021 at 15:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.