x
)- [ X] bug report -> please search issues before submitting
- [ ] feature request
node v8.1.2
npm 5.0.3
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
ubuntu@ip-172-31-5-23:~$ sudo npm install -g @angular/cli
/usr/bin/ng -> /usr/lib/node_modules/@angular/cli/bin/ng
> [email protected] 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' }
> [email protected] install /usr/lib/node_modules/@angular/cli/node_modules/fsevents
> node install
> [email protected] 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 [email protected]
gyp info using [email protected] | 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"
Use case is automating deployment to AWS. Would like to understand steps to avoid this error or for a fix.
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.
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.
Yes this solved the problem. thank you!
Fixing the permissions as said here did not fix the problem for me.
@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
I get: "chown: missing operand after ‘/usr/lib/node_modules/" when trying to run that. What am I missing?
@danindiana is this your problem: https://askubuntu.com/questions/533217/changing-ownership-of-folder-not-working ?
@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 !!
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
@FaroukMohameden you mean the too many symbolic links loop? I get this loop when I run sudo npm i -g @angular/cli
twice.
@Martin-Wegner i mean the loop in #17431 not #1734, sorry !!. And yes, it might be because of trying to install CLI twice.
Use this command
sudo npm install -g @angular/cli@latest --unsafe-perm
To avoid the loop. npm install node-sass then sudo npm i -g @angular/cli
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
@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/
andsudo 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
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._
Most helpful comment
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.