Angular-cli: Installation error: permission denied for node-sas

Created on 30 Jun 2017  路  35Comments  路  Source: angular/angular-cli

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.

> [email protected] 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' }

> [email protected] 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

> [email protected] 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 [email protected]
gyp info using [email protected] | 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: [email protected] (node_modules/@angular/cli/node_modules/node-sass):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] postinstall: `node scripts/build.js`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

Most helpful comment

sudo npm install -g --unsafe-perm --verbose @angular/cli

All 35 comments

May want to check out #6800

Closing as a duplicate of #6800.

I run chown it's worked
sudo chown -r XXX /usr/lib/node_modules/ or sudo chown -r XXX /usr/lib/node_modules/@angular/
if not it might chgrp
sudo chgrp -r XXX /usr/lib/node_modules/

sudo npm install -g --unsafe-perm --verbose @angular/cli

Run following commands
npm i -g npm-check-updates
npm-check-updates -u
npm install

@pushkalb123

and you see in log:

...
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/build'
...

[npm-check] Update complete!
[npm-check] @angular/[email protected]

馃槶

still same issue

Please anyone help me on this, this issue only on ios

@bhumin3i try to reInstall ngCli with root permissions

and check this https://github.com/angular/angular-cli/issues/6800

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 have faced and fixed this issue relates node-sass and python error.Try installing latest angular cli command with the steps below

Set the system variable path as well:
C:UserswindowsusernameAppDataRoamingnpm

C:UserswindowsusernameAppDataRoamingnpmnode_modules@angularclibin;

C:Program Filesnodejs;

Then start using angular cli command prompt using:
angular client project folder path>npm install -g @latest

angular client project folder path>npm install -g node-gyp

Error - gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/**
/git/angular-webpack/node_modules/node-sass/build'*

  1. sudo npm cache clean -f
  2. npm install --save-dev @angular/cli@latest

is there any new changes pushed in node_scss????

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] | 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/test/git/angular-webpack/node_modules/which/which.js:13:12)
gyp verb which failed at F (/Users/test/git/angular-webpack/node_modules/which/which.js:68:19)
gyp verb which failed at E (/Users/test/git/angular-webpack/node_modules/which/which.js:80:29)
gyp verb which failed at /Users/test/git/angular-webpack/node_modules/which/which.js:89:16
gyp verb which failed at /Users/test/git/angular-webpack/node_modules/isexe/index.js:42:5
gyp verb which failed at /Users/test/git/angular-webpack/node_modules/isexe/mode.js:8:5
gyp verb which failed at FSReqWrap.oncomplete (fs.js:166:21)
gyp verb which failed python2 { Error: not found: python2
gyp verb which failed at getNotFoundError (/Users/test/git/angular-webpack/node_modules/which/which.js:13:12)
gyp verb which failed at F (/Users/test/git/angular-webpack/node_modules/which/which.js:68:19)
gyp verb which failed at E (/Users/test/git/angular-webpack/node_modules/which/which.js:80:29)
gyp verb which failed at /Users/test/git/angular-webpack/node_modules/which/which.js:89:16
gyp verb which failed at /Users/test/git/angular-webpack/node_modules/isexe/index.js:42:5
gyp verb which failed at /Users/test/git/angular-webpack/node_modules/isexe/mode.js:8:5
gyp verb which failed at FSReqWrap.oncomplete (fs.js:166:21)
gyp verb which failed stack: 'Error: not found: python2n

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 a sudo 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.

I'm getting the same error on windows when creating a new project knowing that i did npm install overcoming a proxy .
I'm really stuck

I solved this by simply yarn add node-sass

@saadbinsaeed I'm getting the following error
error https://github.com/doctyper/customizr/tarball/develop: Fetch succeeded for undefined. However, extracting "https://github.com/doctyper/customizr/tarball/develop" resulted in hash "a15f0296a0a2488177085aec4ff42c7aaf5510ef", which did not match the requested hash "845ddb7443eae671efcf5352feaec57d7e6e5f0f".

@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

" npm install -g --unsafe-perm node-sass " . solved the issue.

You Need:
sudo npm install node-gyp -g

npm install --unsafe-perm --force

I solved it by:

  • In the project folder go to node_modules in Finder (on Mac),
  • Get the folder properties using Cmd i
  • Go to Sharing & Permissions
  • Change all permissions from the bottom table to Read & Write
  • Select Apply to enclosed items... from the setting menu under the permission table

This might be a temporary fix until I find a better one.

I had also facing this error. None of the above methods work for me. Please follow this. It's Works like a charm !!

For Installing Node in Ubuntu 16 via npm :-

You can install with npm 5.2.0 Version

If you are using nvm :-

nvm install 8.2.1
nvm use 8.2.1
npm install node-sass

If you are using npm separately then upgrade or downgrade npm version to 5.2.0

npm install node-sass

I had problem to install by Docker container I got the error:

gyp WARN EACCES user "undefined" does not have permission to access the dev dir "/app/node_modules/node-sass/.node-gyp/8.9.1"

Then I added in my Dockerfile:

USER root

# after node installation:
RUN npm config set user root

I think even you aren't using Docker, you can run npm config set user <your-user> that will work.

None of these worked. Only worked , when I used Sudo before every npm commands.
sudo npm install -g node-gyp
sudo npm install

I had problem to install by Docker container I got the error:

gyp WARN EACCES user "undefined" does not have permission to access the dev dir "/app/node_modules/node-sass/.node-gyp/8.9.1"

Then I added in my Dockerfile:

USER root

# after node installation:
RUN npm config set user root

I think even you aren't using Docker, you can run npm config set user <your-user> that will work.

That worked for me on Docker node:10 thanks heaps

with --unsafe-perm should work anyway! I don't think, that using "root" user is a good practice by using docker-images, especially on production-server

@WuglyakBolgoink

with --unsafe-perm should work anyway! I don't think, that using "root" user is a good practice by using docker-images, especially on production-server

Why? root is the default user and all of that will run inside a container (if you're using docker, of course). I believe that's the main purpose of using an isolated context, but you can try set another user anyway.

After throwing everything I knew at it, restarting my computer resolved the issue for me. It's possible that either IntelliJ or my corporate antivirus was interfering with it? Thought I'd share in case someone else is out of ideas :smile:

@adamdport lol, "have you tried turning it off and on again?" nice one!

Hi All,

Please include below command in your route folder.

sudo npm install -g --unsafe-perm node-sass

It's working fine.

No need to worry .
After installing via angular CLI , use following command .
npm install --unsafe-perm=true --allow-root

sudo npm install -g --unsafe-perm --verbose @angular/cli

instead of this just try to install everything as non-root user

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._

Was this page helpful?
0 / 5 - 0 ratings