Skip to content

Error while installing @angular/cli on AWS Ubuntu 16.04 server #6800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
X3QTO opened this issue Jun 24, 2017 · 15 comments
Closed

Error while installing @angular/cli on AWS Ubuntu 16.04 server #6800

X3QTO opened this issue Jun 24, 2017 · 15 comments

Comments

@X3QTO
Copy link

X3QTO commented Jun 24, 2017

Bug Report or Feature Request (mark with an x)

- [ X] bug report -> please search issues before submitting
- [ ] feature request

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

sudo apt-get update

sudo apt-get install python -y

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y build-essential

sudo npm install node-gyp -g
sudo npm install -g @angular/cli

The log given by the failure.

ubuntu@ip-172-31-5-23:~$ sudo npm install -g @angular/cli
/usr/bin/ng -> /usr/lib/node_modules/@angular/cli/bin/ng

> node-sass@4.5.3 install /usr/lib/node_modules/@angular/cli/node_modules/node-sass
> node scripts/install.js

Unable to save binary /usr/lib/node_modules/@angular/cli/node_modules/node-sass/vendor/linux-x64-57 : { Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/@angular/cli/node_modules/node-sass/vendor'
    at Object.fs.mkdirSync (fs.js:890:18)
    at sync (/usr/lib/node_modules/@angular/cli/node_modules/mkdirp/index.js:71:13)
    at Function.sync (/usr/lib/node_modules/@angular/cli/node_modules/mkdirp/index.js:77:24)
    at checkAndDownloadBinary (/usr/lib/node_modules/@angular/cli/node_modules/node-sass/scripts/install.js:111:11)
    at Object.<anonymous> (/usr/lib/node_modules/@angular/cli/node_modules/node-sass/scripts/install.js:154:1)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
  errno: -13,
  code: 'EACCES',
  syscall: 'mkdir',
  path: '/usr/lib/node_modules/@angular/cli/node_modules/node-sass/vendor' }

> fsevents@1.1.2 install /usr/lib/node_modules/@angular/cli/node_modules/fsevents
> node install


> node-sass@4.5.3 postinstall /usr/lib/node_modules/@angular/cli/node_modules/node-sass
> node scripts/build.js

Building: /usr/bin/nodejs /usr/lib/node_modules/@angular/cli/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ '/usr/bin/nodejs',
gyp verb cli   '/usr/lib/node_modules/@angular/cli/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library=' ]
gyp info using node-gyp@3.6.2
gyp info using node@8.1.2 | linux | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` succeeded python2 /usr/bin/python2
gyp verb check python version `/usr/bin/python2 -c "import platform; print(platform.python_version());"` returned: "2.7.12\n"
gyp verb get node dir no --target version specified, falling back to host node version: 8.1.2
gyp verb command install [ '8.1.2' ]
gyp verb install input version string "8.1.2"
gyp verb install installing version: 8.1.2
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 8.1.2
gyp verb ensuring nodedir is created /home/ubuntu/.node-gyp/8.1.2
gyp WARN EACCES user "root" does not have permission to access the dev dir "/home/ubuntu/.node-gyp/8.1.2"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp"
gyp verb tmpdir == cwd automatically will remove dev files after to save disk space
gyp verb command install [ '8.1.2' ]
gyp verb install input version string "8.1.2"
gyp verb install installing version: 8.1.2
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 8.1.2
gyp verb ensuring nodedir is created /usr/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.1.2
gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.1.2"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp"
gyp verb tmpdir == cwd automatically will remove dev files after to save disk space
gyp verb command install [ '8.1.2' ]
gyp verb install input version string "8.1.2"
gyp verb install installing version: 8.1.2
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 8.1.2
gyp verb ensuring nodedir is created /usr/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.1.2
gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.1.2"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp"
gyp verb tmpdir == cwd automatically will remove dev files after to save disk space
gyp verb command install [ '8.1.2' ]
gyp verb install input version string "8.1.2"
gyp verb install installing version: 8.1.2
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 8.1.2
gyp verb ensuring nodedir is created /usr/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.1.2
gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/8.1.2"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp"

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, run npm install, and ng serve.
The problem seems to be this initial error which goes in a loop.

@filipesilva
Copy link
Contributor

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.

@X3QTO
Copy link
Author

X3QTO commented Jun 28, 2017

Yes this solved the problem. thank you!

@FaroukMohameden
Copy link

FaroukMohameden commented Sep 5, 2017

Fixing the permissions as said here did not fix the problem for me.

@Martin-Luft
Copy link

Martin-Luft commented Sep 6, 2017

@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

@danindiana
Copy link

I get: "chown: missing operand after ‘/usr/lib/node_modules/" when trying to run that. What am I missing?

@Martin-Luft
Copy link

@FaroukMohameden
Copy link

@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 !!

@X3QTO
Copy link
Author

X3QTO commented Sep 6, 2017

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

@Martin-Luft
Copy link

@FaroukMohameden you mean the too many symbolic links loop? I get this loop when I run sudo npm i -g @angular/cli twice.

@FaroukMohameden
Copy link

@Martin-Wegner i mean the loop in #17431 not #1734, sorry !!. And yes, it might be because of trying to install CLI twice.

@lakinmohapatra
Copy link

Use this command
sudo npm install -g @angular/cli@latest --unsafe-perm

@estigon
Copy link

estigon commented Apr 4, 2018

To avoid the loop. npm install node-sass then sudo npm i -g @angular/cli

@ovimughal
Copy link

If this doesn't work
sudo npm install -g @angular/cli@latest --unsafe-perm
surely this will work :)
sudo chown -R root:root /usr/lib/node_modules/@angular/
and then
sudo npm install -g @angular/cli@latest

@dimidir
Copy link

dimidir commented May 23, 2019

@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

Thanks!
But that still didnt solve it for me.

After that I added:
sudo chown user:group -R /home/<user>/my-project/
cd my-project
npm install
npm start

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants