Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/node-sass/build'

I am trying to run an Angular application. I execute the ng serve command, but it then shows:

Error: Cannot find module 'node-sass'

like image 423
Rajeev Varshney Avatar asked Apr 05 '18 19:04

Rajeev Varshney


3 Answers

Solution:

You need to change the ownership of folder node_modules, because you use sudo npm install -g node-sass, so its ownership is set to root.

To change the ownership to the current user as group -

sudo chown -R root:$(whoami) /usr/local/lib/node_modules/

sudo chmod -R 775 /usr/local/lib/node_modules/

And never use sudo for an npm-related query.

like image 129
Anirban Sanyal Avatar answered Oct 07 '22 17:10

Anirban Sanyal


Run this command

sudo npm install -g <ModuleName> --unsafe-perm=true --allow-root
like image 44
am2505 Avatar answered Oct 07 '22 18:10

am2505


Try this

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

Or this

sudo npm install -g --unsafe-perm --verbose @angular/cli

like image 22
swati kiran Avatar answered Oct 07 '22 17:10

swati kiran