Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Error: EACCES, mkdir '/usr/local/lib/node_modules/node-sass' - installing globally #1098

Closed
@obust

Description

@obust

Hi, I am trying to install node-sass globally but when I execute this command : npm install node-sass -g
I get the following error :

npm ERR! tar.unpack untar error /Users/myusername/.npm/node-sass/3.2.0/package.tgz
npm ERR! Darwin 14.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "node-sass" "-g"
npm ERR! node v0.12.7
npm ERR! npm  v2.11.3
npm ERR! path /usr/local/lib/node_modules/node-sass
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/node-sass'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/node-sass']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/node-sass',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/node-sass',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack: 
npm ERR!    [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53',
npm ERR!      'FSReqWrap.oncomplete (fs.js:95:15)' ] }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR!     /Users/myusername/npm-debug.log

NB : I don't get any error when I install it locally though...

Can someone help me ?

Activity

xzyfer

xzyfer commented on Aug 22, 2015

@xzyfer
Contributor

Sounds like you don't have permissions. You may have sudo npm installed
globally in the last which messed with npm's global directory's
permissions. It's bad practice to sudo npm for this reason.
On 22 Aug 2015 07:50, "obust" notifications@github.com wrote:

Hi, I am trying to install node-sass globally but when I execute this
command : npm install node-sass -g
I get the following error :

npm ERR! tar.unpack untar error /Users/myusername/.npm/node-sass/3.2.0/package.tgz
npm ERR! Darwin 14.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "node-sass" "-g"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! path /usr/local/lib/node_modules/node-sass
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/node-sass'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/node-sass']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules/node-sass',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/node-sass',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25',
npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53',
npm ERR! 'FSReqWrap.oncomplete (fs.js:95:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/myusername/npm-debug.log

NB : I don't get any error when I install it locally though...

Can someone help me ?


Reply to this email directly or view it on GitHub
#1098.

obust

obust commented on Aug 22, 2015

@obust
Author

If I remember right, I only used sudo command to upgrade Node.js, according to this post http://stackoverflow.com/questions/8191459/how-to-update-node-js

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

Anyhow, I uninstalled Node.js and started over but still have the same issue.
What am I supposed to do ?

saper

saper commented on Aug 22, 2015

@saper
Member

First you need to check your permissions is /usr/local/lib/node_modules. Most probably only root can write there.

If you decide to run sudo npm install -g node-sass make sure you read our TROUBLESHOOTING entry on permissions as well as npm documentation on permissions, because your sudo npm will run our installations scripts as nobody.

obust

obust commented on Aug 22, 2015

@obust
Author

The npm documentation on permissions did the trick.
Thank you for the help.

saper

saper commented on Aug 22, 2015

@saper
Member

🎉

SalahAdDin

SalahAdDin commented on Aug 12, 2017

@SalahAdDin

I have the same problem today:

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

It only happens with node-sass. I haven't problem with other packages:

npm -v: 5.3.0
node -v: v8.3.0
npm list -g --depth=0: 
/usr/lib
├── atom-package-manager@1.18.3
├── autoprefixer@7.0.1
├── babel-cli@6.24.1
├── cordova@7.0.0
├── create-react-app@1.4.0
├── create-react-native-app@1.0.0
├── foundation-cli@2.2.2
├── gulp@4.0.0-alpha.2 (git+https://github.com/gulpjs/gulp.git#38246c3f8b6dbb8d4ef657183e92d90c8299e22f)
├── marked@0.3.6
├── marked-man@0.2.1
├── npm@5.3.0
├── postcss-cli@4.0.0
├── react-native-cli@2.0.1
├── semver@5.4.1
├── webpack@3.5.4
└── yarn@0.28.4
saper

saper commented on Aug 12, 2017

@saper
Member

@SalahAdDin read the above and check the permissions

changed the title [-]Error when installing node-sass globally[/-] [+]Error: EACCES, mkdir '/usr/local/lib/node_modules/node-sass' - installing globally[/+] on Aug 12, 2017
SalahAdDin

SalahAdDin commented on Aug 12, 2017

@SalahAdDin

@saper Yes, i haven't problems with any permission in the other packages installation, also with json-server i hadn't. Why with node-sass?

saper

saper commented on Aug 13, 2017

@saper
Member

Because if you run npm as root (to able to install globally I guess) npm will switch to user nobody when executing scripts.

Other packages either have no scripts in their package.json file or do not need to create additional files in the protected system directories.

PritiKumr

PritiKumr commented on Sep 29, 2017

@PritiKumr

JIC someone's searching for the node permission docs everyone is talking about.

https://docs.npmjs.com/getting-started/fixing-npm-permissions

sopedro

sopedro commented on Dec 23, 2017

@sopedro

i solved my problem with the installation of node-sass.
I just go root and install normally. This fixed the error.

joshSummerhays

joshSummerhays commented on Jan 22, 2018

@joshSummerhays

so i used to have to "sudo" npm everything, updated node and npm and now i dont have to use "sudo" anymore. thats it.

chanceaclark

chanceaclark commented on Feb 14, 2018

@chanceaclark

I solved this issue by running sudo npm install -g --unsafe-perm node-sass.

locked as resolved and limited conversation to collaborators on Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @saper@xzyfer@sopedro@SalahAdDin@PritiKumr

        Issue actions

          Error: EACCES, mkdir '/usr/local/lib/node_modules/node-sass' - installing globally · Issue #1098 · sass/node-sass