21

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!

Thangakumar D
  • 714
  • 5
  • 12
  • 27
  • 1
    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 it – dnp1204 Feb 09 '19 at 23:12
  • @dnp1204 Do you want me to reinstall npm ? – Thangakumar D Feb 09 '19 at 23:15
  • 1
    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 try – dnp1204 Feb 09 '19 at 23:17
  • Read this https://npm.community/t/common-proxy-and-networking-problems/151 if it does not work – dnp1204 Feb 09 '19 at 23:18
  • @dnp1204 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. (_tls_wrap.js:1116:38) gyp ERR! stack at emitNone (events.js:106:13) gyp ERR! stack at TLSSocket.emit (events.js:208:7)` – Thangakumar D Feb 10 '19 at 03:05
  • 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. – Mosrainis Oct 31 '20 at 05:15

9 Answers9

34

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

Nathan
  • 7,853
  • 4
  • 27
  • 50
  • I reinstalled nodejs and did 'npm config set registry http://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. (_tls_wrap.js:1116:38) gyp ERR! stack at emitNone (events.js:106:13) gyp ERR! stack at TLSSocket.emit (events.js:208:7)` – Thangakumar D Feb 10 '19 at 03:06
  • If you're on a WIN environment check out this link: https://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 worked – Nathan Feb 11 '19 at 13:12
  • 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/` – dotNET Dec 27 '21 at 10:46
7

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

mks
  • 73
  • 1
  • 6
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

Obed Amoako
  • 363
  • 4
  • 7
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.

Dave Girvitz
  • 51
  • 1
  • 1
  • Oh man this suggestion just saved me!! Thank you! Even just browsing to https://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. – csichar Sep 15 '20 at 13:02
2

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

Justin
  • 21
  • 1
  • 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](/help/how-to-answer). – Community Aug 03 '22 at 17:06
  • how did u resolve it? – djavaphp May 04 '23 at 17:01
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.

Tellestar
  • 76
  • 1
  • 5
0

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

-2

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

  • 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](/help/how-to-answer). – Community Jan 10 '23 at 10:15
-4

Connect to faster internet in order to install packages.

Andrew Myers
  • 2,754
  • 5
  • 32
  • 40