问题描述
我是nodejs和npm的新手.我正在尝试安装log4js,这是安装命令:
I'm new to nodejs and npm. I'm trying to install log4js and this is the command for the install:
npm install log4js
我正在Windows命令行上运行它,经过一段时间的标记旋转后,出现以下错误:
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
我尝试按照以下建议执行npm config set ca=""
: http://blog.npmjs.org/post/78085451721/npms-self-signed-certificate-is-no-more ,但我仍然收到此错误.
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.
我该如何解决并安装NPM?
How can I solve this and install NPMs ?
推荐答案
发生此错误是因为npm客户端的旧版本使用了绑定到客户端本身的证书颁发机构(CA)文件,该文件无法与最新的SSL一起使用节点证书.
This error occurred because Old versions of the npm client used a certificate authority (CA) file that was bundled into the client itself which would not work with the latest SSL certificate of Node.
按照npm 博客 LTS不受此问题的影响,因此最好使用最新的版本
下列任何一个步骤均出现此错误应该可以帮助您
1)升级您的npm版本
As per npm blog LTS is not affected by this issue, so prefer using Latest release
However if you have this error either of steps below should help you
1) upgrade your version of npm
npm install npm -g --ca=null
2)告诉您当前版本的npm使用节点的ca而不是内置npm的ca
npm config set ca=""
3)您也可以禁用strict-ssl模式来解决旧版本中的错误,但您要擦除安全性
npm set strict-ssl false
npm install npm -g --ca=null
2) tell your current version of npm to use node's ca instead of built in npm's canpm config set ca=""
3) you can also disable strict-ssl mode to get around the error in old version, but you are wiping the securitynpm set strict-ssl false
这篇关于nodejs" npm ERR!代码SELF_SIGNED_CERT_IN_CHAIN";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!