Search code examples
node.jsangularnpm

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'


Solution

  • 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.