nodejs “npm ERR! code SELF_SIGNED_CERT_IN_CHAIN”

2020-02-07 17:07发布

I'm new to nodejs and npm. I'm trying to install log4js and this is the command for the install:

npm install log4js

I'm running this from Windows Command Line and I after a while of a marker spinning I get the following error:

npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "log4js"
npm ERR! node v0.12.0
npm ERR! npm  v2.5.1
npm ERR! code SELF_SIGNED_CERT_IN_CHAIN

npm ERR! self signed certificate in certificate chain
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     C:\srv\npm-debug.log

I tried doing npm config set ca="" like suggested here: http://blog.npmjs.org/post/78085451721/npms-self-signed-certificate-is-no-more but I'm still getting this error.

How can I solve this and install NPMs ?

标签: node.js npm
9条回答
Root(大扎)
2楼-- · 2020-02-07 17:19

I had the same problem on windows 10.

open windows powerShell and enter the following command:

npm config set registry http://registry.npmjs.org/

Then you can use:

npm install [your package]
查看更多
We Are One
3楼-- · 2020-02-07 17:20

I'm new to npm as well. Besides the commands mentioned in your link I tried the following and it resolved my issues:

  • npm set strict-ssl false
  • disabled McAfee temporarily

Reference: Npm SELF_SIGNED_CERT_IN_CHAIN on Azure

查看更多
在下西门庆
4楼-- · 2020-02-07 17:26

In my case, I had installed Fiddler, which has a self signed certificate which made the npm install go crazy.

See here how to remove the self signed Fiddler certificate How do you remove the root CA certificate that Fiddler installs

查看更多
老娘就宠你
5楼-- · 2020-02-07 17:35

Did you also tried settings cafile accommodating all pems in one file? npm add root CA

If you use proxy in your .npmrc file, I will suggest to set no_proxy environment variable with value of your <server IP address>

查看更多
在下西门庆
6楼-- · 2020-02-07 17:35

In CentOS and other Linux distros you need to configure NPM to use your Certificate Authorities file:

npm config set cafile "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" -g

Obviously check the file exists and contains all CA Roots you may encounter (e.g. corporate proxy).

查看更多
狗以群分
7楼-- · 2020-02-07 17:39

As metioned by Akshay Vijay Jain above,

npm config set strict-ssl false

TURNING OFF SSL BEFORE INSTALLING THE LATEST VERSION

Then install the latest version

npm install -g npm@latest

INSTALL SUCCESS!!

See the screenshots added for clarity.

查看更多
登录 后发表回答