npm registry – including for package installation – must use TLS 1.2 or higher

We got the issue when tried to run npm audit to check security issues. The npm audit command did not work. It showed the following message on the console:

npm WARN audit 426 Upgrade Required - POST http://registry.npmjs.org/-/npm/v1/security/audits/quick
Beginning October 4, 2021, all connections to npm websites and the npm registry - including for package installation - must use HTTPS and TLS 1.2 or higher.

For more information see this blog post: https://github.blog/2021-08-23-npm-registry-deprecating-tls-1-0-tls-1-1/

The warning message is very self-descriptive. It says the npm registry must use HTTPS and TLS 1.2 or higher. If you are seeing this message then your npm registry is not using HTTPS.

We can solve this two ways:

  • Updating the npm to the latest version
  • Updating the npm registry

Updating the npm to the latest version:

$ npm install npm@latest -g

Updating the npm registry:

$ npm config set registry https://registry.npmjs.org/