Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM node-sass installation fails

I am trying to install node-sass in a project, which perfectly builds and runs on my pc but on my surface I am having major issues when trying to install the packages.

Note: I have tryed reinstalling and rebuilding the project several times.

Summary of the error:

gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\Max-T\Documents\Sources\StaffMangerV2\black-dashboard-pro-react-v1.0.0\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Max-T\\Documents\\Sources\\StaffMangerV2\\black-dashboard-pro-react-v1.0.0\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Users\Max-T\Documents\Sources\StaffMangerV2\black-dashboard-pro-react-v1.0.0\node_modules\node-sass
gyp ERR! node -v v12.13.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\react-scripts\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

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\Max-T\AppData\Roaming\npm-cache\_logs\2019-10-30T10_05_01_386Z-debug.log

package.json => https://hastebin.com/azetegukes.pl too much coode so I had to paste it elsewhere.

like image 550
Maxdola Avatar asked Oct 30 '19 10:10

Maxdola


Video Answer


5 Answers

You're using Node 12, and node-sass needs to be at least 4.12 to support that version https://github.com/sass/node-sass#node-version-support-policy

like image 113
nschonni Avatar answered Oct 10 '22 10:10

nschonni


If anyone runs into this lately... the easiest fix is to replace node-sass with just sass in your dependencies. It's the more recently maintained version and I only had to change 1 line of code with how it's initialized and all of my existing code was already compatible.

There are more details at https://sass-lang.com/blog/libsass-is-deprecated under How to migrate.

like image 42
Matt Toigo Avatar answered Oct 10 '22 09:10

Matt Toigo


try this command it works for me

sudo npm install -g --unsafe-perm node-sass
like image 30
Alireza Ebrahimkhani Avatar answered Oct 10 '22 11:10

Alireza Ebrahimkhani


After more than 2 hours of trying all sorts of ways (cleaning npm cache, deleting node_modules, trying to install with global switch -g, etc.) to install node-sass and failing every time, I finally changed the mirror to china and it immediately worked for me!! (I know it kinda doesn't make any sense, considering the error I was getting)

Just for reference, this was the error I was receiving before it finally worked:

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\****\AppData\Roaming\npm-cache\_logs\2020-06-06T13_56_56_768Z-debug.log

My Node version: v12.18.0
node-sass version in package.json: "^4.14.0"

I changed the mirror as stated in the node-sass npm page.

npm install -g mirror-config-china --registry=http://registry.npm.taobao.org
npm install node-sass

Hope that helps.

like image 45
Sнаđошƒаӽ Avatar answered Oct 10 '22 11:10

Sнаđошƒаӽ


Don't use node-sass anymore

node-sass is deprecated. Instead use the new version which is sass.

You can uninstall the old and install the new one with this command

npm uninstall node-sass
npm install sass


like image 3
Abraham Avatar answered Oct 10 '22 10:10

Abraham