I’m having trouble with npm install. It’s giving me a weird error about not being able to get a local issuer certificate. Here’s what I’m seeing:
npm ERR! RequestError: unable to get local issuer certificate
// ... (truncated stack trace)
I’m working on a Node.js project (version 23.10.0) and this error pops up when I try to install packages. It looks like it’s related to SSL issues.
I’ve already tried several things:
Disabling SSL checks using NODE_TLS_REJECT_UNAUTHORIZED=0
Reviewing my proxy settings
Clearing the npm cache
Using the --legacy-peer-deps flag
Adjusting NODE_EXTRA_CA_CERTS for a custom certificate
None of these steps have resolved the issue. Has anyone experienced something similar or have any ideas on what might be causing this problem? Could it be specific to my environment or a known issue with certain versions of Node.js or npm?
I’ve dealt with this exact problem before, and it was a real headache. In my case, the issue turned out to be related to an outdated CA certificate bundle on my system. Here’s what finally worked for me:
First, I updated my system’s CA certificates. On most Linux distros, you can do this with ‘sudo update-ca-certificates’. For macOS, I had to install a fresh copy of the Mozilla CA certificate bundle.
After that, I set the NODE_EXTRA_CA_CERTS environment variable to point to the updated bundle. Something like:
Then I restarted my terminal and tried ‘npm install’ again. It worked like a charm after that.
If you’re on Windows, you might need to update your root certificates through the system settings. It’s a bit more involved, but there are guides online.
Hope this helps you get unstuck. SSL certificate issues can be tricky, but once you solve it, you’re usually good for a while.
I encountered a similar issue recently. What resolved it for me was manually setting the npm registry to use HTTP instead of HTTPS temporarily. You can try this by running:
This workaround bypasses SSL certificate validation, which isn’t ideal from a security perspective, but it can help determine if the problem is certificate-related. Also, check your system time since an incorrect clock can lead to SSL validation failures. If you’re behind a corporate network, consulting your IT department may be necessary to ensure the proper certificates are trusted.
hey nova56, had similar issue. try updating npm to latest version (npm install -g npm@latest). if that fails, check ur network settings. sometimes corporate firewalls mess with ssl. also, try running npm with --verbose flag to get more info. good luck!