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
Description
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 commentedon 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:
obust commentedon 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
Anyhow, I uninstalled Node.js and started over but still have the same issue.
What am I supposed to do ?
saper commentedon Aug 22, 2015
First you need to check your permissions is
/usr/local/lib/node_modules
. Most probably onlyroot
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 yoursudo npm
will run our installations scripts asnobody
.obust commentedon Aug 22, 2015
The npm documentation on permissions did the trick.
Thank you for the help.
saper commentedon Aug 22, 2015
🎉
SalahAdDin commentedon Aug 12, 2017
I have the same problem today:
It only happens with
node-sass
. I haven't problem with other packages:saper commentedon Aug 12, 2017
@SalahAdDin read the above and check the permissions
[-]Error when installing node-sass globally[/-][+]Error: EACCES, mkdir '/usr/local/lib/node_modules/node-sass' - installing globally[/+]SalahAdDin commentedon Aug 12, 2017
@saper Yes, i haven't problems with any permission in the other packages installation, also with
json-server
i hadn't. Why withnode-sass
?saper commentedon 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 commentedon Sep 29, 2017
JIC someone's searching for the node permission docs everyone is talking about.
https://docs.npmjs.com/getting-started/fixing-npm-permissions
sopedro commentedon 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 commentedon Jan 22, 2018
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 commentedon Feb 14, 2018
I solved this issue by running
sudo npm install -g --unsafe-perm node-sass
.