【问题标题】:407 Proxy error when npm install behind a corporate proxynpm install 在公司代理后面时出现 407 代理错误
【发布时间】:2019-11-14 03:58:42
【问题描述】:

在公司代理后面运行 npm install 时出现 http 407 错误。

我已经在环境变量中设置了这样的代理:


    export http_proxy://usernamewithoutspecialchars:passwdwithoutspecialchars@my.proxy.fr
    export https_proxy://usernamewithoutspecialchars:passwdwithoutspecialchars@my.proxy.fr

我还编辑了我的 ~/.npmrc 配置以添加我的代理:

registry=https://xxxxxx/artifactory/api/npm/proxy-npm/
_auth="my_base64_auth_here="
email=geraud.xxx@xxxxxxxx.fr
always-auth=true
cafile=/home/geraud/chain_bundle.pem
strict-ssl=false
proxy=http_proxy://usernamewithoutspecialchars:passwdwithoutspecialchars@my.proxy.fr
https-proxy=http_proxy://usernamewithoutspecialchars:passwdwithoutspecialchars@my.proxy.fr

最后我跑了

npm set registry xxxx
npm set proxy http_proxy://usernamewithoutspecialchars:passwdwithoutspecialchars@my.proxy.fr
npm set https_proxy http_proxy://usernamewithoutspecialchars:passwdwithoutspecialchars@my.proxy.fr

但是这些方法都不适合我。 我什至直接运行 npm install --registry xxx --proxy xxxx 但仍然无法正常工作。

我通过运行 wget 和 curl 重现了该问题

curl -IL --proxy-user xxxx:xxxxxx https://github.com/sass/node-sass/releases/download/v4.9.0/linux-x64-57_binding.node

wget -d -v --proxy-user=xxxxx --proxy-password=xxxx https://nodejs.org/download/release/v8.11.4/node-v8.11.4-headers.tar.gz

两者都给我 407 错误。 但是当我使用 --digest 参数运行 curl 时,它会成功运行。

这是我的错误日志:

npm i
> node-sass@4.9.0 install /home/geraudbonou/observations/node_modules/node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.9.0/linux-x64-57_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.9.0/linux-x64-57_binding.node": 

tunneling socket could not be established, statusCode=407

Hint: If github.com is not accessible in your location
      try setting a proxy via HTTP_PROXY, e.g. 

      export HTTP_PROXY=http://example.com:1234

or configure npm proxy via

      npm config set proxy http://example.com:8080
.....

gyp verb download using proxy url: "http://xxx:xxxx@xxx.proxy.xxx.xxx:8080/"
gyp WARN install got an error, rolling back install
gyp verb command remove [ '8.11.4' ]
gyp verb remove using node-gyp dir: /home/geraudbonou/.node-gyp
gyp verb remove removing target version: 8.11.4
gyp verb remove removing development files for version: 8.11.4
gyp ERR! configure error 
gyp ERR! stack Error: tunneling socket could not be established, statusCode=407
gyp ERR! stack     at ClientRequest.onConnect (/home/geraudbonou/observations/node_modules/tunnel-agent/index.js:166:19)
gyp ERR! stack     at Object.onceWrapper (events.js:319:30)
gyp ERR! stack     at emitThree (events.js:136:13)
gyp ERR! stack     at ClientRequest.emit (events.js:217:7)
gyp ERR! stack     at Socket.socketOnData (_http_client.js:474:11)
gyp ERR! stack     at emitOne (events.js:116:13)
gyp ERR! stack     at Socket.emit (events.js:211:7)
gyp ERR! stack     at addChunk (_stream_readable.js:263:12)
gyp ERR! stack     at readableAddChunk (_stream_readable.js:250:11)
gyp ERR! stack     at Socket.Readable.push (_stream_readable.js:208:10)
gyp ERR! System Linux 4.18.0-25-generic
gyp ERR! command "/usr/bin/node" "/home/geraudbonou/observations/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /home/geraudbonou/observations/node_modules/node-sass
gyp ERR! node -v v8.11.4
gyp ERR! node-gyp -v v3.7.0
gyp ERR! not ok

【问题讨论】:

标签: node.js proxy angular6 npm-install


【解决方案1】:

我在谷歌上搜索更改代理但不适合我

在 Windows 上,你可以用管理员试试 cmd,它也可以工作

【讨论】:

    猜你喜欢
    • 2014-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多