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 ?
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" [email protected] 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 -13npm 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
https://github.com/sass/node-sass/issues/1098.
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 ?
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.
The npm documentation on permissions did the trick.
Thank you for the help.
:tada:
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:
```bash
npm -v: 5.3.0
node -v: v8.3.0
npm list -g --depth=0:
/usr/lib
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected] (git+https://github.com/gulpjs/gulp.git#38246c3f8b6dbb8d4ef657183e92d90c8299e22f)
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
โโโ [email protected]
@SalahAdDin read the above and check the permissions
@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?
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.
JIC someone's searching for the node permission docs everyone is talking about.
https://docs.npmjs.com/getting-started/fixing-npm-permissions
i solved my problem with the installation of node-sass.
I just go root and install normally. This fixed the error.
so i used to have to "sudo" npm everything, updated node and npm and now i dont have to use "sudo" anymore. thats it.
I solved this issue by running sudo npm install -g --unsafe-perm node-sass.
Most helpful comment
First you need to check your permissions is
/usr/local/lib/node_modules. Most probably onlyrootcan write there.If you decide to run
sudo npm install -g node-sassmake sure you read our TROUBLESHOOTING entry on permissions as well as npm documentation on permissions, because yoursudo npmwill run our installations scripts asnobody.