更新时间:2024-10-09 GMT+08:00
执行Npm构建时,报错提示node-sass下载失败
问题现象
执行Npm构建任务时,日志报如下异常信息:
Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/linux-x64-72_binding.node Cannot download "https://github.com/sass/node-sass/releases/download/v4.14.1/linux-x64-72_binding.node": read ECONNRESET ... npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! node-sass@4.14.1 postinstall: `node scripts/build.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the node-sass@4.14.1 postinstall script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
原因分析
node-sass的镜像源需要单独设置,如果没有设置,npm默认会去github下载。从软件开发生产线到github的网络不太稳定,容易下载失败。
处理方法
在默认命令npm install之前先加上如下命令,选择使用华为云的mirror源,重新执行构建即可。
npm config set sass_binary_site https://repo.xxcloud.com/node-sass/
父主题: Npm构建