Fix npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY on Windows

beginner๐ŸชŸ Windows2026-07-24| Windows 10/11, Node.js v14+, npm v6+

Error Message

npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY
#npm#nodejs#ssl#windows-11#devops

Decoding the ErrorFew things stall a project faster than a wall of red text in your terminal. If you just tried to run npm install and were greeted by an UNABLE_TO_GET_ISSUER_CERT_LOCALLY error, you're likely dealing with a certificate trust issue. This usually happens when npm tries to connect to the registry but can't verify the security certificate provided by your network.

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/package-name failed

The Root CauseCorporate firewalls, VPNs, and antivirus software (like Zscaler or Cisco Umbrella) often intercept HTTPS traffic to scan for threats. They do this by replacing the original website certificate with their own self-signed version.

While Windows might trust this custom certificate, Node.js does not. Node.js uses its own built-in list of trusted Certificate Authorities (CAs) instead of the Windows Certificate Store. When it sees a certificate it doesn't recognize, it kills the connection for your protection.

Solution 1: The 5-Second Fix (Not Recommended for Production)Need a quick workaround for a personal project? You can tell npm to stop being so strict about SSL. This is the fastest way to get back to work, but it creates a security hole. It leaves you vulnerable to Man-in-the-Middle (MitM) attacks because npm will no longer verify who it's talking to.

Run this in your terminal:

npm config set strict-ssl false

Once you finish your installation, you should probably turn it back on to stay safe:

npm config set strict-ssl true

Solution 2: The Secure Approach (Recommended)The right way to fix this is to teach Node.js to trust your company's certificate. Youโ€™ll need to grab the root certificate (usually a small 2KB .pem or .cer file) and point npm to it.

How to export the certificate via Chrome:- Visit https://registry.npmjs.org in your browser.- Click the Lock icon in the address bar > Connection is secure > Certificate is valid.- Open the Details tab. Choose the top-most certificate in the hierarchy (the Root CA).- Click Export and save it as a Base64-encoded X.509 (.CER) file.Once saved, tell npm where to find it:

npm config set cafile "C:\Users\YourName\Documents\root-cert.pem"

Solution 3: Set a Global Environment VariableSometimes fixing npm isn't enough. Other tools like VS Code extensions or Node-based build scripts might still fail. You can solve this for all Node.js applications at once by setting a system environment variable.

  • Press the Windows Key and type "env". Select Edit the system environment variables.- Click Environment Variables at the bottom right.- Under User variables, click New.- Set the name to NODE_EXTRA_CA_CERTS.- Set the value to the full path of your certificate (e.g., C:\certs\company-ca.pem).Note: You must close and reopen your terminal or VS Code for this change to take effect.

Verification: Did it work?Confirm your settings are active by checking your config list:

npm config list

Look for the cafile or strict-ssl lines. To test it for real, try installing a tiny, dependency-free package like is-number:

npm install is-number

If the progress bar moves without throwing the ISSUER_CERT error, you're good to go.

Pro-Tips for Corporate Devs- Check for Internal Mirrors: Many companies host their own npm registry (like Nexus or Artifactory). Ask your DevOps team if you should be using a URL like https://artifacts.company.com/api/npm/npm-repo/ instead of the public registry.- Local .npmrc: If you only need these settings for one specific project, create a file named .npmrc in your project root. Add strict-ssl=false there. This keeps your global settings secure while letting that one project build.- Update Node.js: If you are on a very old version (like Node 12 or 14), upgrading to the latest LTS (Long Term Support) version often resolves certificate handshake issues.

Related Error Notes