在公司代理后面运行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
答案 0 :(得分:0)
我正在谷歌更改代理但对我不起作用
在Windows上,您可以与管理员一起尝试cmd,它也可以正常工作