Skip to content
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

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

Closed
obust opened this issue Aug 21, 2015 · 13 comments
Closed

Comments

@obust
Copy link

obust commented Aug 21, 2015

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 ?

@xzyfer
Copy link
Contributor

xzyfer commented Aug 22, 2015

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
Copy link
Author

obust commented Aug 22, 2015

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
Copy link
Member

saper commented Aug 22, 2015

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
Copy link
Author

obust commented Aug 22, 2015

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

@obust obust closed this as completed Aug 22, 2015
@saper
Copy link
Member

saper commented Aug 22, 2015

🎉

@SalahAdDin
Copy link

SalahAdDin commented Aug 12, 2017

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
Copy link
Member

saper commented Aug 12, 2017

@SalahAdDin read the above and check the permissions

@saper saper changed the title Error when installing node-sass globally Error: EACCES, mkdir '/usr/local/lib/node_modules/node-sass' - installing globally Aug 12, 2017
@SalahAdDin
Copy link

@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
Copy link
Member

saper commented Aug 13, 2017

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
Copy link

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

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

@sopedro
Copy link

sopedro commented Dec 23, 2017

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

@joshSummerhays
Copy link

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
Copy link

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

@sass sass locked as resolved and limited conversation to collaborators Feb 14, 2018
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

8 participants