原文网址:npm--解决npm install时github的read ECONNRESET问题_IT利刃出鞘的博客-CSDN博客
简介
本文介绍解决npm install时github的read ECONNRESET问题。
问题复现
在下载node-sass时,报错了。
命令是:
npm install -D [email protected]
报错信息:
> node scripts/install.js
Downloading binary from https://github.com/sass/node-sass/releases/download/v6.0.1/win32-x64-83_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v6.0.1/win32-x64-83_binding.node":
read ECONNRESET
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
> [email protected] postinstall E:\work\WebStorm_proj\demo_FrontEnd\demo_vue_scss\node_modules\node-sass
> node scripts/build.js
Building: D:\dev\nodejs\node.exe E:\work\WebStorm_proj\demo_FrontEnd\demo_vue_scss\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
原因分析
是连接到github失败导致的。
解决方案
1. 设置registry
npm config set registry http://registry.npmmirror.com
2. 设置proxy
npm config set proxy=http://127.0.0.1:8087