Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gyp ERR! stack Error: EACCES: permission denied, mkdir '/var/www/project_name/node_modules/node-sass/build'

I'm deploying an Angular project on Ububtu 16.04 and get these errors when I run sudo npm install. (won't work without sudo). It seems that npm doesn't have permission to install. I recently updated to nodejs to 8.11.4 and still have the same error so it wasn't a version problem apparently. How can I give it the correct permissions?

gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/var/www/project_name/node_modules/node-sass/build'
gyp ERR! System Linux 4.4.0-1065-aws
gyp ERR! command "/usr/local/bin/node" "/var/www/project_name/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "-libsass_library="
gyp ERR! cwd /var/www/front-stormsensor/node_modules/node-sass
gyp ERR! node -v v8.11.4
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
Build failed with error code: 1

Is there something off within my project? Or an incorrect installation? Not sure where to go from here, thank you

like image 889
LaurenAH Avatar asked Sep 08 '18 01:09

LaurenAH


6 Answers

try the following command

sudo npm i --unsafe-perm

if it doesn't work try the following

sudo rm -rf ~/.node-gyp
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
sudo npm i --unsafe-perm
like image 132
jNambiar Avatar answered Nov 17 '22 17:11

jNambiar


I fixed it by run this command.

sudo npm i --unsafe-perm

like image 9
Khachornchit Songsaen Avatar answered Nov 17 '22 16:11

Khachornchit Songsaen


In case you're installing something globally, you can use:

$ sudo npm install -g <package> --unsafe-perm
like image 8
Jimmy Adaro Avatar answered Nov 17 '22 16:11

Jimmy Adaro


use following command to install

sudo npm install --unsafe-perm=true --allow-root

like image 8
JHM16 Avatar answered Nov 17 '22 18:11

JHM16


This solution from jnambiar worked for me. My OS is OSX 10.11.6. It's basically permissions issue.

sudo rm -rf ~/.node-gyp
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
sudo npm i --unsafe-perm

Above set of commands helped me resolve the issue. I am posting this to approve the set of commands which worked for me while I struggled to install the node-sass package for 2 days.

like image 3
Chem_Lab Avatar answered Nov 17 '22 18:11

Chem_Lab


For anyone that might still have this problem, I solved it by following the suggestion of the second comment above and logging in as the root user on my ubuntu instance, as described in the second answer on this question here.. That allowed me to npm install without errors.

like image 1
LaurenAH Avatar answered Nov 17 '22 18:11

LaurenAH