当我尝试使用 npm 安装包时,它无法工作。经过长时间的等待,我最终得到一个错误‘ tunneling socket could not be create,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)
然而,当我在我的网页浏览器(谷歌浏览器)中浏览同一个网址时,它载入正常(见脚注)
怎么了?
虽然我碰巧使用了 https 代理,但我确信这不是问题所在。我已经配置了环境变量 https_proxy
(根据 npm 用户指南)。我知道环境变量是正确的,因为 Python 包管理器 pip
正确地遵循了它。
I believe the problem relates to SSL certificates, because if I download that URL with wget
, I get an explicit error about certificates
$ 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”证书安装为“受信任的根认证机构”(截图 < img src = “ https://i.stack.imgur.com/0H57J.png”alt = “ enter image description here”>)
编辑: 我尝试了每个 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