I am trying to run an Angular application. I execute the ng serve
command, but it then shows:
Error: Cannot find module 'node-sass'
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.
Run this command
sudo npm install -g <ModuleName> --unsafe-perm=true --allow-root
Try this
sudo npm install -g --unsafe-perm node-sass
Or this
sudo npm install -g --unsafe-perm --verbose @angular/cli
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With