How to Use the npm strict ssl Command: Check, Disable, Undo

Updated

npm strict ssl

npm strict ssl isn’t a command of its own: strict-ssl is an npm config setting that you read and change with npm config. It defaults to true, and npm config get strict-ssl shows the value npm is using. npm config set strict-ssl false stops npm from validating the registry’s HTTPS certificate, so I’d use it only to test whether a certificate is the problem, then undo it. If a corporate proxy is behind the error, make Node trust the proxy’s root certificate instead.

Check the npm strict ssl setting

npm config get strict-ssl   # true unless something overrides it
npm config get cafile       # null unless someone set it
npm config list             # shows which file each value comes from

These commands work the same in npm 10, 11 and 12. npm 12 is the current major as of October 1, 2026, and npm --version shows which one you have. If strict-ssl doesn’t appear in npm config list, nothing is overriding the default.

What npm config set strict-ssl false turns off

npm config set strict-ssl false

This adds strict-ssl=false to your user .npmrc. From then on npm stops validating the certificate the registry presents, which npm’s config reference calls “SSL key validation”. The connection is still HTTPS, but npm can no longer tell the real registry from something impersonating it. An unknown issuer, a self-signed certificate in the chain or any other failed check is accepted instead of raising an error.

Anyone on the network path can then answer as the registry, read the credentials npm sends it (an _authToken from your .npmrc, for example) and tamper with what comes back. Node’s documentation says of its process-wide switch, NODE_TLS_REJECT_UNAUTHORIZED=0, that it “makes TLS, and HTTPS by extension, insecure.” The setting also hides problems instead of fixing them: a wrong CA setting keeps failing the check, and strict-ssl=false only stops npm from reporting it.

Where strict-ssl is set: .npmrc, environment variable or flag

npm takes the value from the first of these that sets it:

  1. a command-line flag, such as npm install --strict-ssl=false
  2. an environment variable, npm_config_strict_ssl=false (underscores instead of dashes)
  3. the project .npmrc, next to package.json
  4. your user ~/.npmrc, which is where npm config set writes by default
  5. the global $PREFIX/etc/npmrc
  6. npm’s built-in npmrc, in its own install folder

npm config list shows which one is winning. It prints a block per source and marks any value that a higher source overrides:

; "project" config from /home/me/app/.npmrc

; strict-ssl = false ; overridden by env

; "env" config from environment

strict-ssl = true

get and list ignore --location, so get always prints the winning value. --location chooses the file for set, delete and edit.

Turn strict-ssl back on with npm config delete

npm config delete strict-ssl
npm config get strict-ssl

The second command should print true again. delete edits one file: your user .npmrc, unless you add --location=project or --location=global. If get still prints false, look in npm config list for the source that sets it. A flag or an environment variable has to be removed where it is set.

Fix proxy certificate errors without disabling strict-ssl

If a corporate proxy re-signs HTTPS traffic with your company’s own root CA, npm fails with errors such as UNABLE_TO_GET_ISSUER_CERT_LOCALLY (“unable to get local issuer certificate”), UNABLE_TO_VERIFY_LEAF_SIGNATURE or SELF_SIGNED_CERT_IN_CHAIN, because Node doesn’t trust that CA. The fix is to make Node trust it while validation stays on. I cover that error on its own in npm unable to get local issuer certificate. These are the options:

Option Certificate checks Needs
strict-ssl=false Off, for npm’s registry requests Any npm
NODE_EXTRA_CA_CERTS On. Adds your CA to Node’s built-in list, for every Node program Any Node version
--use-system-ca On. Adds the operating system’s trusted CAs, for every Node program Node 22.15 or later, including 24 and 26 (not 20 or 18)
NODE_USE_SYSTEM_CA=1 Same as the flag Node 22.19 or later, 24.6 or later, and 26
cafile or ca On, but only against the CAs you supply: the built-in list is replaced, for npm only Any npm

NODE_EXTRA_CA_CERTS

I’d start here. Node extends its well-known root CAs with the certificates in the file, so the proxy and the public registry both keep working, and other Node tools benefit too.

# macOS or Linux (add the line to ~/.zshrc or ~/.bashrc to keep it)
export NODE_EXTRA_CA_CERTS=/path/to/corp-root-ca.pem

# Windows PowerShell, current session
$Env:NODE_EXTRA_CA_CERTS = "C:\certs\corp-root-ca.pem"

# Windows, for terminals opened later
setx NODE_EXTRA_CA_CERTS "C:\certs\corp-root-ca.pem"

Point it at your company’s root CA certificate in PEM format, not at the proxy’s or the registry’s own server certificate. npm’s docs note that Windows calls PEM “Base-64 encoded X.509 (.CER)”. Ask your IT team for the file if you don’t have it. Node reads the variable only at startup, and a missing or malformed file gives a warning at most, so open a new terminal and recheck the path if the error stays.

--use-system-ca

If IT has already put the root CA in the operating system’s trust store, Node can read that store instead of a file. Set NODE_USE_SYSTEM_CA=1 the same way as above, or pass the --use-system-ca flag through NODE_OPTIONS, for example NODE_OPTIONS=--use-system-ca npm install on macOS or Linux. On Windows and macOS it reads the system certificate stores. On Linux it uses the OpenSSL default locations, typically /etc/ssl/certs. Every Node version that npm 12 supports has both the flag and the variable.

cafile and ca

npm config set cafile /path/to/ca-bundle.pem

These are npm-only settings: cafile takes a file of PEM certificates and ca takes the certificate text itself. npm hands them to Node as the complete list of CAs to trust, and Node’s documentation says the default list is then “completely replaced (instead of being concatenated)”. That also switches off NODE_EXTRA_CA_CERTS and --use-system-ca for npm. A file with only your corporate root works while the proxy re-signs everything npm connects to, but it fails with UNABLE_TO_GET_ISSUER_CERT_LOCALLY anywhere the real registry certificate is used, such as when you’re off the VPN. If you need cafile, add the public roots to the same bundle. npm silently ignores a cafile path that doesn’t exist, and npm config delete cafile removes a stale one.

strict-ssl in pnpm and Yarn

pnpm and Yarn have the same switch, also on by default. pnpm 10 reads strict-ssl from .npmrc, while pnpm 11 and 12 use strictSsl in pnpm-workspace.yaml. Yarn 4 uses enableStrictSsl in .yarnrc.yml, with httpsCaFilePath for a CA file.

Photo of author
Sudhir P. founded HeatWare.com in 1999 and has built and operated it full-stack ever since; it is now used by more than 88,000 people. He writes here about the PostgreSQL, MySQL, Linux and DevOps work that keeps it running. Articles are rewritten only after the commands in them have actually been run, and the verification scripts are published alongside them so anyone can check the claims. Reach him at blog@heatware.net.