Simple solution for node sass installation failure

problem

installing node-sass encountered the following error

PS E:\phoneEmall\phone-emall> npm i node-sass

> [email protected] install E:\phoneEmall\phone-emall\node_modules\node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-64_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-64_binding.node":

HTTP error 404 Not Found

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:\phoneEmall\phone-emall\node_modules\node-sass
> node scripts/build.js

Building: C:\Program Files\nodejs\node.exe E:\phoneEmall\phone-emall\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli   'E:\\phoneEmall\\phone-emall\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library=' ]
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (E:\phoneEmall\phone-emall\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (E:\phoneEmall\phone-emall\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (E:\phoneEmall\phone-emall\node_modules\which\which.js:80:29)
gyp verb `which` failed     at E:\phoneEmall\phone-emall\node_modules\which\which.js:89:16
gyp verb `which` failed     at E:\phoneEmall\phone-emall\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at E:\phoneEmall\phone-emall\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:153:21)
gyp verb `which` failed  python2 { Error: not found: python2
gyp verb `which` failed     at getNotFoundError (E:\phoneEmall\phone-emall\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (E:\phoneEmall\phone-emall\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (E:\phoneEmall\phone-emall\node_modules\which\which.js:80:29)
gyp verb `which` failed     at E:\phoneEmall\phone-emall\node_modules\which\which.js:89:16
gyp verb `which` failed     at E:\phoneEmall\phone-emall\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at E:\phoneEmall\phone-emall\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:153:21)
gyp verb `which` failed   stack:
gyp verb `which` failed    'Error: not found: python2\n    at getNotFoundError (E:\\phoneEmall\\phone-emall\\node_modules\\which\\which.js:13:12)\n    at F (E:\\phoneEmall\\phone-emall\\node_modules\\which\\which.js:68:19)\n    at E (E:\\phoneEmall\\phone-emall\\node_modules\\which\\which.js:80:29)\n    at E:\\phoneEmall\\phone-emall\\node_modules\\which\\which.js:89:16\n    at E:\\phoneEmall\\phone-emall\\node_modules\\isexe\\index.js:42:5\n    at E:\\phoneEmall\\phone-emall\\node_modules\\isexe\\windows.js:36:5\n    at FSReqWrap.oncomplete (fs.js:153:21)',
gyp verb `which` failed   code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python C:\Users\Administrator\AppData\Local\Programs\Python\Python37\python.EXE
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Users\Administrator\AppData\Local\Programs\Python\Python37\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack     at ChildProcess.emit (events.js:189:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:970:16)
gyp ERR! stack     at Socket.stream.socket.on (internal/child_process.js:389:11)
gyp ERR! stack     at Socket.emit (events.js:189:13)
gyp ERR! stack     at Pipe._handle.close (net.js:597:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "E:\\phoneEmall\\phone-emall\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd E:\phoneEmall\phone-emall\node_modules\node-sass
gyp ERR! node -v v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN [email protected] requires a peer of webpack@^1.12.6 || ^2.1.0-beta but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of webpack@^1.0.0 || ^2.0.0 || ^3.0.0 but
none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of webpack@>=1.3.0 <3 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2019-07-12T03_34_51_589Z-debug.log

to find the answer

looked at the error message, and saw that there was a 404 in the file download. Then I searched for the file and found the hosts file. I thought it was a python problem, and then I reinstalled various versions of python…

took 3 hours, tried countless answers on the Internet, no solution

solution

improved the version number of sass-loader and node-sass to the latest version, the current latest version is as follows (July 12, 2019)
“sass-loader” : “^7.1.0”,
“node-sass” : “^4.12.0”,

as shown in the figure, modify the package.json file

then execute the following command to install

npm i sass-loader
npm i node-sass

2020-05-06 update

the problem is often the cause of the Node – sass version problem, may be one reason for this is that: because version too old so will cause some dependencies have already can’t find it, the company has a four years ago old projects is this kind of problem, the modified Node – sass version 4.12 is not necessarily suitable for all projects, can test several versions, if the above version failed can try this version

"node-sass": "^4.13.1",
"sass-loader": "^4.1.1",

What if

still fails?

my answer may not be right for you, but you have to believe in the bright side.

a keen discussion program + financial management person, welcome to exchange ~

Read More: