Reputation: 369
I am unable to install Angular Cli globally through npm.
I keep getting this error when I run npm install -g @angular/cli
on macOS:
npm ERR! node v6.9.2
npm ERR! npm v3.10.9
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! at Error (native)
npm ERR! { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! at Error (native)
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules' }
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! /Users/apple/npm-debug.log
Upvotes: 26
Views: 74790
Reputation: 150
**
Don't worry!!
** Just use command form Root user like Ex -
And All Set
Upvotes: -1
Reputation: 1
EACCES: permission denied, symlink '../lib/nod code example Example 1: Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
sudo npm install -g nodemon //easiest fix
Example 2: npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/@angular/cli/bin/ng' -> '/usr/bin/ng' sudo npm install -g @angular/cli sudo chown -R $USER /usr/local/lib/node_modules
Upvotes: -1
Reputation: 1107
create a directory for global installations:
mkdir ~/.npm-global
Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
create a ~/.profile
file
add this line to your new ~/.profile
file:
export PATH=~/.npm-global/bin:$PATH
update your system variables:
source ~/.profile
Reference: Resolving EACCES permissions errors when installing packages globally
Upvotes: 7
Reputation: 29
Use:
sudo npm install -g @angular/cli
Then it will work, mine was also not working, but it worked with sudo.
Upvotes: 0
Reputation: 7524
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.
Upvotes: 39
Reputation: 4177
I had this problem on Linux, where the repository was on a partition that was mounted with option noexec
. Remounting the partition with exec
solved it for me.
I had installed node through nvm, which is the recommended way to avoid permission issues. But if nvm can't execute in your folder, it won't work in some cases.
Upvotes: 1
Reputation: 11
This was a great link for me.
https://flaviocopes.com/npm-fix-missing-write-access-error/
once I did this command
sudo chown -R $USER /usr/local/lib/node_modules
in my terminal, the angular CLI install worked perfectly!
Upvotes: 1
Reputation: 1030
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.
Upvotes: 24
Reputation: 1595
The answer by Ayush is what I tried at first. Yet the problem persisted. Maybe I didn't do all the steps correctly , I am not sure. So again I looked up Google and found this link https://github.com/angular/angular-cli/issues/7735#issuecomment-345546822. There are two ways to go about solving it. Luckily the first way worked for me. The step that might have made a difference may be compared to what Ayush mentioned above in the answers:
$ echo -e "export PATH=$(npm prefix -g)/bin:$PATH" >> ~/.bashrc
$ source ~/.bashrc
I am using Ubuntu though! Anyways it is solved now. :)
Upvotes: 0
Reputation: 348
WARNING: Check that $(npm config get prefix)
does not point to /usr
by typing echo $(npm config get prefix)
I solved like that
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
Worked for me
Upvotes: 6
Reputation: 385
I fixed the issue by running
sudo npm install -g @angular/cli
After prompting for password enter it.
Then you will be able to install.
Upvotes: 3
Reputation: 55
Hello Please Follow my guide to install angular 4 from the cli without any permission issues:
Install the angular-cli
globally
sudo npm install -g @angular/cli
Create a new project
ng new my-app --skip-install
Serve the application
sudo chown <username> -R my-app
cd my-app
mkdir node_modules
chmod a+w node_modules
npm install
ng serve --open
Upvotes: -1