angular-cli: Installation error: permission denied for node-sas
Installation error (node-sass) with:
node version 8.1.2 npm version 5.0.3
I recently updated node from 7.5.0 to 8.1.2 (with nvm). Installing the latest @angular/cli now results in this error:
The log given by the failure.
> node-sass@4.5.3 install /Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/node-sass
> node scripts/install.js
Unable to save binary /Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/node-sass/vendor/darwin-x64-57 : { Error: EACCES: permission denied, mkdir '/Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/node-sass/vendor'
at Object.fs.mkdirSync (fs.js:890:18)
at sync (/Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/mkdirp/index.js:71:13)
at Function.sync (/Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/mkdirp/index.js:77:24)
at checkAndDownloadBinary (/Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/node-sass/scripts/install.js:111:11)
at Object.<anonymous> (/Users/macliems/.nvm/versions/node/v8.1.2/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: '/Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/node-sass/vendor' }
> fsevents@1.1.2 install /Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/fsevents
> node install
[fsevents] Success: "/Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile
> node-sass@4.5.3 postinstall /Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/node-sass
> node scripts/build.js
Building: /Users/macliems/.nvm/versions/node/v8.1.2/bin/node /Users/macliems/.nvm/versions/node/v8.1.2/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 [ '/Users/macliems/.nvm/versions/node/v8.1.2/bin/node',
gyp verb cli '/Users/macliems/.nvm/versions/node/v8.1.2/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 | darwin | 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` failed Error: not found: python2
gyp verb `which` failed at getNotFoundError (/Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/which/which.js:13:12)
gyp verb `which` failed at F (/Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/which/which.js:68:19)
gyp verb `which` failed at E (/Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/which/which.js:80:29)
gyp verb `which` failed at /Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/which/which.js:89:16
gyp verb `which` failed at /Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/isexe/index.js:42:5
gyp verb `which` failed at /Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/isexe/mode.js:8:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:152:21)
gyp verb `which` failed python2 { Error: not found: python2
gyp verb `which` failed at getNotFoundError (/Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/which/which.js:13:12)
gyp verb `which` failed at F (/Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/which/which.js:68:19)
gyp verb `which` failed at E (/Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/which/which.js:80:29)
gyp verb `which` failed at /Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/which/which.js:89:16
gyp verb `which` failed at /Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/isexe/index.js:42:5
gyp verb `which` failed at /Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/isexe/mode.js:8:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:152:21)
gyp verb `which` failed stack: 'Error: not found: python2\n at getNotFoundError (/Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/which/which.js:13:12)\n at F (/Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/which/which.js:68:19)\n at E (/Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/which/which.js:80:29)\n at /Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/which/which.js:89:16\n at /Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/isexe/index.js:42:5\n at /Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/isexe/mode.js:8:5\n at FSReqWrap.oncomplete (fs.js:152:21)',
gyp verb `which` failed code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python /usr/bin/python
gyp verb check python version `/usr/bin/python -c "import platform; print(platform.python_version());"` returned: "2.7.10\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 is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 8.1.2
gyp verb build dir attempting to create "build" dir: /Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/node-sass/build
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/node-sass/build'
gyp ERR! System Darwin 16.6.0
gyp ERR! command "/Users/macliems/.nvm/versions/node/v8.1.2/bin/node" "/Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/macliems/.nvm/versions/node/v8.1.2/lib/node_modules/@angular/cli/node_modules/node-sass
gyp ERR! node -v v8.1.2
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass@4.5.3 (node_modules/@angular/cli/node_modules/node-sass):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass@4.5.3 postinstall: `node scripts/build.js`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 34
- Comments: 35 (2 by maintainers)
sudo npm install -g --unsafe-perm --verbose @angular/cli
Agreed, check out: https://docs.npmjs.com/getting-started/fixing-npm-permissions
Run following commands npm i -g npm-check-updates npm-check-updates -u npm install
" npm install -g --unsafe-perm node-sass " . solved the issue.
I was getting the same frustrating error, it’s definitely a permissions issue. If you’ve been using NPM with sudo for a while and don’t want to go through the hassle of reinstalling everything (at least not right in the middle of a project) I think I found a quick fix.
node-sass refused to install whether I used sudo or not, so I looked at my project directory -
ls -ahl
and saw that my node_modules directory was set to user root I’m assuming as a consequence of using sudo. I ran asudo chown yourname:yourgroup node_modules
where yourname/yourgroup is the name/group of all your other non-root controlled files and then ran (without sudo)npm i node-sass -D
This did the trick. Just a suggested shortcut.
npm install --unsafe-perm --force
I run chown it’s worked
sudo chown -r XXX /usr/lib/node_modules/
orsudo chown -r XXX /usr/lib/node_modules/@angular/
if not it might chgrpsudo chgrp -r XXX /usr/lib/node_modules/
I solved this by simply
yarn add node-sass
Closing as a duplicate of #6800.
May want to check out #6800
You Need: sudo npm install node-gyp -g
I had the same issue on MacOs. I fixed.
@bhumin3i
try this install first node-gyp sudo npm install node-gyp -g and then install or update the angular sudo npm install -g -f @angular/cli@latest
this was my error in a loop
gyp verb command install [ ‘9.4.0’ ] gyp verb install input version string “9.4.0” gyp verb install installing version: 9.4.0 gyp verb install --ensure was passed, so won’t reinstall if already installed gyp verb install version not already installed, continuing with install 9.4.0 gyp verb ensuring nodedir is created /usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/9.4.0 gyp WARN EACCES user “root” does not have permission to access the dev dir “/usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/.node-gyp/9.4.0” gyp WARN EACCES attempting to reinstall using temporary dev dir “/usr/local/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
I had problem to install by Docker container I got the error:
Then I added in my Dockerfile:
I think even you aren’t using Docker, you can run
npm config set user <your-user>
that will work.I solved it by:
node_modules
in Finder (on Mac),Cmd i
Sharing & Permissions
Read & Write
Apply to enclosed items...
from the setting menu under the permission tableThis might be a temporary fix until I find a better one.
instead of this just try to install everything as non-root user
@Mona-Superscientist Are you using the yarn? Try upgrading it to latest version. But first try it by removing your lock file and reinstalling the node modules
@pushkalb123
and you see in log:
😭