Hello everyone!
I’ve been facing a frustrating issue while trying to install packages in my Node.js project using npm install. I keep getting this error:
npm ERR! RequestError: unable to get local issuer certificate
npm ERR! at ClientRequest.<anonymous> (file:///path/to/node_modules/got/dist/source/core/index.js:790:107)
npm ERR! at Object.onceWrapper (node:events:622:26)
npm ERR! at ClientRequest.emit (node:events:519:35)
npm ERR! at emitErrorEvent (node:_http_client:104:11)
npm ERR! at TLSSocket.socketErrorListener (node:_http_client:518:5)
npm ERR! at TLSSocket.emit (node:events:507:28)
npm ERR! at emitErrorNT (node:internal/streams/destroy:170:8)
npm ERR! at emitErrorCloseNT (node:internal/streams/destroy:129:3)
npm ERR! at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
npm ERR! at TLSSocket.onConnectSecure (node:_tls_wrap:1679:34)
npm ERR! at TLSSocket.emit (node:events:507:28)
npm ERR! at TLSSocket._finishInit (node:_tls_wrap:1078:8)
npm ERR! at ssl.onhandshakedone (node:_tls_wrap:864:12)
Context:
I’m working in a Node.js environment and have dependencies that I need to install. The RequestError is due to SSL/TLS certificate issues, preventing successful installation of packages.
Here’s what I’ve done to try and fix it:
- Disabling SSL Verification: Tried running
NODE_TLS_REJECT_UNAUTHORIZED=0 npm install
, but it didn’t help. - Proxy Settings: My setup might involve a proxy, so I checked and updated the proxy settings in the .npmrc file, but still encountered the error.
- Clear npm Cache: I executed
npm cache clean --force
, yet the problem persists. - Using --legacy-peer-deps: Tried installing with the
--legacy-peer-deps
flag, but it also didn’t resolve my issue. - Setting Custom CA Certificates: Attempted to use
NODE_EXTRA_CA_CERTS
to point to a custom CA certificate, but this didn’t solve the problem either.
Additional Details:
- Node.js version is 23.10.0.
- The error appears when attempting to download dependencies from the internet.
- I suspect this might be linked to working in a corporate network due to the corporate proxy.
Help Needed:
Has anyone experienced this before? What solutions have worked to navigate SSL validation issues with npm and Node.js?