Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NodeJS OSX error building node-sass

I am running OSX 10.11.1 and trying to npm install a project that contains a node-sass dependency in the package.json:

"dependencies": { "node-sass": "^3.4.2" }

I am running NPM version 2.14.7 and node version 4.2.3. When I run npm install or npm rebuild node-sass I get the following error output:

> [email protected] postinstall /Users/markroper/code/mktg/node_modules/gulp-sass/node_modules/node-sass
> node scripts/build.js
gyp: /Users/markroper/.node-gyp/4.2.3/common.gypi not found (cwd: /Users/markroper/code/mktg/node_modules/gulp-sass/node_modules/node-sass) while reading includes of binding.gyp while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/markroper/code/mktg/node_modules/gulp-sass/node_modules/node-sass/node_modules/pangyp/lib/configure.js:346:16)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 15.0.0
gyp ERR! command "/usr/local/bin/node" "/Users/markroper/code/mktg/node_modules/gulp-sass/node_modules/node-sass/node_modules/pangyp/bin/node-gyp" "rebuild"
gyp ERR! cwd /Users/markroper/code/mktg/node_modules/gulp-sass/node_modules/node-sass
gyp ERR! node -v v4.2.3
gyp ERR! pangyp -v v2.3.3
gyp ERR! not ok 
Build failed

Has anyone worked around this error with these versions?

like image 647
Mark Roper Avatar asked Dec 10 '15 13:12

Mark Roper


People also ask

Does node Sass work with node 16?

node-sass not compatible with newer versions of node, such as 14 and 16.

Why do I have to rebuild node sass?

When you change the version of Node. js used on your project, then the binding needs to be rebuild so that node-sass can be imported and executed from your code. Once the rebuild is finished, run the project again. Once done, you should be able to run the project without any errors.

What can I use instead of node sass?

Sass, Webpack, PostCSS, Compass, and Animate. css are the most popular alternatives and competitors to node-sass.

Is node Sass deprecated?

Warning: LibSass and Node Sass are deprecated. While they will continue to receive maintenance releases indefinitely, there are no plans to add additional features or compatibility with any new CSS or Sass features. Projects that still use it should move onto Dart Sass.


1 Answers

Add --unsafe-perm flag while installing

For linux/mac

sudo npm install --unsafe-perm -g node-sass

For windows environment , hit same command removing sudo

like image 167
Sri Vivek Avatar answered Sep 28 '22 01:09

Sri Vivek