我在ubuntu上使用npm v1.0.104/node 0.6.12 -当我试图通过npm安装任何新模块时,我收到了下面的错误。IO之前使用http,而不是HTTPS &我想知道这是否会导致npm/unsigned certs的问题)。当npm试图解析“https://registry.npmjs.org”URL时,错误就会弹出。有没有办法我可以忽略错误,或者找到/添加证书到可信存储,以便继续使用npm。

任何关于需要做什么来解决问题的见解都将受到感谢(如果可能的话,我更喜欢通过配置来解决问题,而不是重新安装)。

错误:" SSL错误:SELF_SIGNED_CERT_IN_CHAIN"

完整的信息:

npm ERR! Error: SSL Error: SELF_SIGNED_CERT_IN_CHAIN
npm ERR!     at ClientRequest.<anonymous> (/usr/lib/node_modules/npm/node_modules/request/main.js:252:28)
npm ERR!     at ClientRequest.emit (events.js:67:17)
npm ERR!     at HTTPParser.onIncoming (http.js:1261:11)
npm ERR!     at HTTPParser.onHeadersComplete (http.js:102:31)
npm ERR!     at CleartextStream.ondata (http.js:1150:24)
npm ERR!     at CleartextStream._push (tls.js:375:27)
npm ERR!     at SecurePair.cycle (tls.js:734:20)
npm ERR!     at EncryptedStream.write (tls.js:130:13)
npm ERR!     at Socket.ondata (stream.js:38:26)
npm ERR!     at Socket.emit (events.js:67:17)
npm ERR! Report this *entire* log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>
npm ERR! 
npm ERR! System Linux 2.6.38-13-generic
npm ERR! command "node" "/usr/bin/npm" "install" "jed"
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.0.104

当前回答

现在我只是把注册表URL从https切换到http。是这样的:

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

其他回答

执行以下命令帮助解决该问题:

npm config set strict-ssl false

目前我还不能评论它是否会引起任何其他问题。

对于那些在mac上有同样问题并通过homebrew安装npm的人:

brew uninstall npm

then

brew install npm

适用于osx (10.9.1)

编辑:你可能需要在安装npm之前酿造更新。您还可以在更新自制程序后进行brew升级。此外,如果您遇到任何其他问题,运行brew doctor可能会有所帮助。

快速干净的解决方案(linux测试)(2014年2月27日fatidic之后)


卸载 npm

npm rm npm -g

安装npm(新的URL是www.npmjs.org而不是npmjs.org)

curl https://www.npmjs.org/install.sh | sh

提示:如何在linux https://stackoverflow.com/a/22099363/333061中安装node.js

npm config set strict-ssl false -g

在全球范围内保存

现在我只是把注册表URL从https切换到http。是这样的:

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