npm throws EACCES error on installation of Angular CLI

  1. create a directory for global installations:

    mkdir ~/.npm-global

  2. Configure npm to use the new directory path:

    npm config set prefix '~/.npm-global'

  3. create a ~/.profile file

  4. add this line to your new ~/.profile file:

    export PATH=~/.npm-global/bin:$PATH

  5. update your system variables:

    source ~/.profile

Reference: Resolving EACCES permissions errors when installing packages globally


Try using this: On the command line, in your home directory, create a directory for global installations:

mkdir ~/.npm-global

Configure npm to use the new directory path:

npm config set prefix '~/.npm-global'

In your preferred text editor, open or create a ~/.profile file and add this line:

export PATH=~/.npm-global/bin:$PATH

On the command line, update your system variables:

source ~/.profile

Test installing package globally without using sudo. Now run npm install -g @angular/cli it should work.


When you use npm install -g on any platform and you get EACCES, you are writing to a directory for which you do not have write permission.

Some may recommend using sudo, but this will lead to more problems in the future. The npm documentation provides options to fix this.

I highly recommend using a node version manager like nodenv as the solution.