1

After npm install -g @angular/cli this is what I recive:

npm WARN optional Skipping failed optional dependency /@angular/cli/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
npm ERR! Linux 4.15.0-38-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "@angular/cli"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! path /usr/local/lib
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access

npm ERR! Error: EACCES: permission denied, access '/usr/local/lib'
npm ERR!  { Error: EACCES: permission denied, access '/usr/local/lib'
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/ipaulbogdan/npm-debug.log

2 Answers 2

1

From https://www.npmjs.com/package/@angular/cli#installation

Install Globablly

npm install -g @angular/cli

Install Locally

npm install @angular/cli

In Linux, every time you install something, when that something is Global means you need root access and when something is Local just with your user is enough


To translate that into commands

Global

sudo npm install -g @angular/cli

Local

npm install @angular/cli


Permission Denied

You can see what is the problem clearly in the log

npm ERR! Error: EACCES: permission denied, access '/usr/local/lib'

Probably the installer wants to write there but can's because only the root user can

2
  • Thanks man.Appreciate your help.It's working now. Commented Nov 29, 2018 at 11:36
  • Please use the answer below to fix the problem. It's not suggested to use sudo to install npm packages on linux. Follow the answer posted by Ashraf Mirghani Commented Mar 11, 2019 at 8:22
1

https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

Back up your computer. 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

To test your new configuration, install a package globally without using sudo:

npm install -g jshint

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.