当我尝试使用npm安装软件包时,它不起作用。漫长的等待后,我最终收到一条错误消息“无法建立隧道套接字,sutatusCode = 403”。
$ npm install coffee-script
npm http GET https://registry.npmjs.org/coffee-script
npm http GET https://registry.npmjs.org/coffee-script
npm http GET https://registry.npmjs.org/coffee-script
npm ERR! Error: tunneling socket could not be established, sutatusCode=403
npm ERR! at ClientRequest.onConnect (c:\Program Files\nodejs\node_modules\npm\node_modules\request\tunnel.js:148:19)
npm ERR! at ClientRequest.g (events.js:193:14)
npm ERR! at ClientRequest.EventEmitter.emit (events.js:123:20)
npm ERR! at Socket.socketOnData (http.js:1393:11)
npm ERR! at TCP.onread (net.js:403:27)
但是,当我在网络浏览器(Google Chrome)中浏览到相同的URL时,它加载正常(请参阅脚注)。https://registry.npmjs.org/coffee-script
怎么了
当我碰巧使用https代理时,我相信这不是问题。我已经配置了环境变量https_proxy
(根据npm用户指南)。我知道环境变量是正确的,因为Python包管理器pip
正确地遵循了它。
我认为问题与SSL证书有关,因为如果我使用下载该URL wget
,则会收到有关证书的显式错误
$ wget https://registry.npmjs.org/coffee-script
SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
syswgetrc = c:/progra~1/wget/etc/wgetrc
--2012-12-17 12:14:07-- https://registry.npmjs.org/coffee-script
Resolving corpproxy... 10.254.215.35
Connecting to corpproxy|10.254.215.35|:8080... connected.
ERROR: cannot verify registry.npmjs.org's certificate, issued by `/C=US/ST=CA/L=Oakland/O=npm/OU=npm Certificate Authority/CN=npmCA/emailAddress=i@izs.me':
Unable to locally verify the issuer's authority.
To connect to registry.npmjs.org insecurely, use `--no-check-certificate'.
Unable to establish SSL connection.
我怎样才能解决这个问题?在不影响安全性的前提下。
我以前也经常在网络浏览器中收到SSL证书错误,直到我在“控制面板”的“ Internet选项”(屏幕截图)中将“ npmCA”证书安装为“受信任的根证书颁发机构”
编辑:我尝试了每个https://npmjs.org/doc/config.html#strict-ssl不安全的解决方法
npm set strict-ssl false
但是它仍然超时并显示相同的错误
$ npm install coffee-script
npm http GET https://registry.npmjs.org/coffee-script
npm http GET https://registry.npmjs.org/coffee-script
npm http GET https://registry.npmjs.org/coffee-script
npm ERR! Error: tunneling socket could not be established, sutatusCode=403