Help Center/ CodeArts Build/ FAQs/ Using npm for Build/ Failed to Download node-sass
Updated on 2023-11-28 GMT+08:00

Failed to Download node-sass

Symptoms

When the npm build task is executed, the following error information is displayed in the log:

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.

Cause Analysis

The image source of node-sass needs to be set separately. If the mirror source is not set, npm downloads the mirror source from GitHub by default. The network between CodeArts and GitHub is unstable, and the download may fail.

Solution

Add the following command before the default command npm install to use the image source of Huawei Cloud and perform the build again.

npm config set sass_binary_site https://repo.xxcloud.com/node-sass/