Solvedangular cli Error while installing @angular/cli on AWS Ubuntu 16.04 server
✔️Accepted Answer
This seems to be a problem with installing https://github.com/sass/node-sass, which is one of the dependencies.
The problem most likely arises from the use of sudo
, which is heavily discouraged while installing packages. Check out https://docs.npmjs.com/getting-started/fixing-npm-permissions to see how you can fix your permissions.
Other Answers:
Per the npm video, I chose option 2. I use a different directory for npm globals. This works without any issues for me.
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo "export PATH=~/.npm-global/bin:$PATH" >> ~/.profile
source ~/.profile
npm i -g @angular/cli
Use this command
sudo npm install -g @angular/cli@latest --unsafe-perm
@Martin-Wegner , thank u (y). I managed to install it using the first two steps you mentionned as root. I have to mention that the second step sudo npm i -g @angular/cli
took me to an infinite loop like in #1734. So i bypassed it using @totomz 's answer on the same issue e.g sudo npm i -g --unsafe-perm @angular/cli
. And : yes, the script is not good at all !!
@FaroukMohameden the Angular CLI npm install script is not very good... The problem is, that the installer script wants to put the symbolic link ng
to /usr/bin/
so you need sudo... But with sudo you cannot install it because...the installer script is not very good ;) But don't worry, you can install it this way:
1.) Fix the permissions by changing the ownership and group of /usr/lib/node_modules/
to your user account: sudo chown -r XXX /usr/lib/node_modules/
and sudo chgrp -r XXX /usr/lib/node_modules/
2.) sudo npm i -g @angular/cli
3.) sudo rm -fr /usr/lib/node_modules/@angular/cli/
4.) sudo chown -r XXX /usr/lib/node_modules/@angular/
5.) sudo chgrp -r XXX /usr/lib/node_modules/@angular/
6.) npm i -g @angular/cli
Bug Report or Feature Request (mark with an
x
)Versions.
node v8.1.2
npm 5.0.3
Repro steps.
Setup new AWS Ubuntu Server: Ubuntu Server 16.04 LTS (HVM), SSD Volume Type - ami-d15a75c7
Then run commands below
The log given by the failure.
Desired functionality.
Use case is automating deployment to AWS. Would like to understand steps to avoid this error or for a fix.
Mention any other details that might be useful.
The error keeps repeating. Breaking out the error using Ctrl +C, and then reinstalling using:
sudo npm install -g @angular/cli
seems to work.
I can then run
ng new myproject
, runnpm install
, andng serve
.The problem seems to be this initial error which goes in a loop.