7

I am attempting to install node-sass and it just won't let me. I have tried updating npm.

I put this in:

sudo npm install -g node-sass

and i get this (starting one line before the error):

gyp verb build dir attempting to create "build" dir: 
/Users/matt/node_modules/node-sass/build
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir 
'/Users/matt/node_modules/node-sass/build'
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/usr/local/bin/node" 
"/Users/matt/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "- 
-verbose" "--libsass_ext=" "--libsass_cflags=" "-- 
libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/matt/node_modules/node-sass
gyp ERR! node -v v8.11.1
gyp ERR! node-gyp -v v3.7.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN enoent ENOENT: no such file or directory, open                     
'/Users/matt/package.json'
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but         
none is installed. You must install peer dependencies yourself.
npm WARN matt No description
npm WARN matt No repository field.
npm WARN matt No README data
npm WARN matt No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.9.2 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.9.2 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!     /Users/matt/.npm/_logs/2018-08-02T16_18_15_228Z- 
debug.log
Matt Wright
  • 71
  • 1
  • 1
  • 2

7 Answers7

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

This must fix the problem

deepakssn
  • 4,655
  • 2
  • 20
  • 19
1

Permission problem to your directory '/Users/matt/node_modules/node-sass/build' kindly right click on Users/matt and go to properties uncheck ReadOnly then on the same window move to security check fro every user whether the full control is given for the folder else change it to full-control for Everyone

Vaibhav Kumar Goyal
  • 1,391
  • 12
  • 17
  • I have the same problem when running the Ionic tutorial, and the problem is that the node-sass directory is being installed at runtime: `> node-sass@4.9.0 install /Users/imacuser/MyIonicProject/node_modules/node-sass`, resulting in the same error as @Matt : `gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/matt/node_modules/node-sass/build'`. How do you set permissions on a directory that doesn't exist and won't install, because of the denied permissions? – jimiayler Aug 08 '18 at 01:45
  • @jimiayler It’s your parent directory that would be the problem ie your project folder e.g.- angular-project > node modules so the problem is with angular-project directory – Vaibhav Kumar Goyal Aug 08 '18 at 01:49
  • ok can you right click on your parent directory of the project and go to security tab and give permission to Everyone as Full Control ,also just check whether readonly is unchecked for your parent directory, try installing again @jimiayler – Vaibhav Kumar Goyal Aug 08 '18 at 06:27
1

The best way to get rid of permission issues is by installing npm/node using brew.

  1. Uninstall npm (How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X))
  2. Install brew /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  3. Install node/npm by using the following command brew install node
deepakssn
  • 4,655
  • 2
  • 20
  • 19
1

try this command:

sudo npm install --save-dev  --unsafe-perm node-sass
Shashin Bhayani
  • 1,347
  • 3
  • 13
  • 34
1

Workaround, that makes this works:

Go to the folder

username/.npm/node-sass // on linux
username/AppData/Roaming/npm-cache/node-sass //on windows

inside create directory /4.9.2

From this page https://github.com/sass/node-sass-binaries get specific version and put this file inside 4.9.2 folder. Now try run npm installation - should work!

Kamil Naja
  • 4,390
  • 4
  • 25
  • 38
0

For me these things didn't work and I had the same issue but I was able to solve it through another app that had the binary for node-sass in the vendor folder so I sudo mv the folder to my other project and it was able to run it ok. I know it might not be a good solution but that was something that I tried that worked.

scotth527
  • 57
  • 6
  • Can you explain further, please? What other app did you get the binary from? – mypetlion Jul 10 '19 at 16:20
  • My local computer doesn't have the issue with installing the full node-sass folder in node_modules ( so it actually had the binary for node_sass) i sudo mv the node-sass file with the binary I believe it had the vendor folder inside, into the node_module/node-sass folder that didn't have the binary. Again I don't think this is the best solution but it somehow made it work for me – scotth527 Jul 13 '19 at 22:12
0

I had something similar going on, if nothing from above helps you try to remove the proxy first.
I had an npm ERR! code ECONNREFUSED issue while trying to install node-sass, so check in your logs if this is happening to you.
If a proxy exists remove it with this command:

npm config set proxy null
npm config set https-proxy null

next, set npm to download from the official package registry:

npm config set registry http://registry.npmjs.org/

Then install your package with npm install node-sass