Warning "root" does not have permission to access the dev dir
tjwebb opened this issue Β· 66 comments
For people coming here through search engines, see #454 (comment)
gyp WARN EACCES user "root" does not have permission to access the dev dir "/home/travis/.node-gyp/0.10.28"
I'm filing this here because node-gyp
is the only package that seems to throw this issue. My project depends on some modules which build with node-gyp
, and I see this warning for every one of them during 'npm install'. Does anyone have insight on what this warning means?
[help] same with me....
ferdinan@ferdinan:~/Documents/aplikasi-saya$ sudo npm install -g yo
[sudo] password for ferdinan:
> fullname-native@0.1.1 install /usr/lib/node_modules/yo/node_modules/fullname/node_modules/fullname-native
> node-gyp rebuild
gyp ERR! UNCAUGHT EXCEPTION
gyp ERR! stack Error: EPERM, utime '/home/ferdinan/.node-gyp/0.10.29'
gyp ERR! System Linux 3.13.0-24-generic
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/lib/node_modules/yo/node_modules/fullname/node_modules/fullname-native
gyp ERR! node -v v0.10.29
gyp ERR! node-gyp -v v0.13.1
gyp ERR! This is a bug in `node-gyp`.
gyp ERR! Try to update node-gyp and file an Issue if it does not help:
gyp ERR! <https://github.com/TooTallNate/node-gyp/issues>
npm WARN optional dep failed, continuing fullname-native@0.1.1
anybody can help me to solved...!!!
Yep, I'm getting a very similar error. In my case, it happens after running:
npm install grunt-browserify
I get:
fsevents@0.2.0 install <directory_name>/node_modules/grunt-browserify/node_modules/watchify/node_modules/chokidar/node_modules/fsevents
node-gyp rebuildgyp WARN EACCES user "" does not have permission to access the dev dir "/<my root user directory, (~)>/.node-gyp/0.10.29"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/var/folders/_c/0g7gkjgs3_955vxcyp7y5xc40000gn/T/.node-gyp"
CXX(target) Release/obj.target/fse/fsevents.o
SOLINK_MODULE(target) Release/fse.node
SOLINK_MODULE(target) Release/fse.node: Finished
After that, I get the usual npm module installed boilerplate.
I get the same message when I run the command with root privileges, except with 'user "root" does not have permission...'
This error began happening after I upgraded node from version 0.10.21 to version 0.10.29 using the install package at http://nodejs.org/. I can see that the folder it's expecting, ~/.node-gyp/0.10.29, doesn't exist. If it helps, I'm running Mac OS X 10.9.3.
I wish I knew more about the project and could suggest a fix, but I thought I'd post, just to bring it to your attention.
Cheers!
Update: as expected, everything works fine and I have no warning if I just change the name of the folder at ~/.node-gyp/0.10.21 to 0.10.29, matching my version change. I suspect those of you on Linux having a similar problem could make a similar fix. Hope it's not gonna break anything under the hood...
If I remember correctly, set unsafe-perm
to true
when running as sudo
is a fix it's obstructing.
I'm also seeing this on SmartOS/illumos/Solaris
+1
gyp WARN EACCES user "root" does not have permission to access the dev dir "/Users/XXX/.node-gyp/0.10.32"
Doesn't look like the project maintainer cares much about this issue
I solved it by using chown on the .node-gyp folder and cleaning cache if I remember correctly.
Same problem here. Using Ubuntu 14.04. chown on the node-gyp folder did not fix the issue :(
Solved it be adding --unsafe-perm
.
In my case with sails:
sudo npm install --unsafe-perm --verbose -g sails
Works well!
why should I set 'unsafe-perm ' =true ,what's the meaning of "unsafe-perm"?
I met the same problem
"2:~ herrdu$ sudo npm install -g hexo
Password:
Sorry, try again.
Password:
fsevents@0.2.0 install /usr/local/lib/node_modules/hexo/node_modules/chokidar/node_modules/fsevents
node-gyp rebuild
gyp WARN EACCES user "root" does not have permission to access the dev dir "/Users/herrdu/.node-gyp/0.10.32"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/hexo/node_modules/chokidar/node_modules/fsevents/.node-gyp"
"
Do you find the solution?And can you show it in detail ?
And if I create the direction ".node-gyp herrdu$ mrdir 0.10.32" ,the error is
fsevents@0.2.0 install /usr/local/lib/node_modules/hexo/node_modules/chokidar/node_modules/fsevents
node-gyp rebuild
gyp ERR! UNCAUGHT EXCEPTION
gyp ERR! stack Error: EPERM, chmod '/Users/herrdu/.node-gyp/0.10.32'
gyp ERR! System Darwin 13.4.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/hexo/node_modules/chokidar/node_modules/fsevents
gyp ERR! node -v v0.10.32
gyp ERR! node-gyp -v v1.0.1
gyp ERR! This is a bug in node-gyp
.
gyp ERR! Try to update node-gyp and file an Issue if it does not help:
gyp ERR! https://github.com/TooTallNate/node-gyp/issues
npm WARN optional dep failed, continuing fsevents@0.2.0'
Then I can't solve it!!!
How come this is still an outstanding issue? Why is gyp even used by NPM if it's this broken with no clear solution? I've seen people recommend rm -rf ~/tmp
and using --unsafe-perm
but those haven't made a difference for me on my CentOS server.
This error occurred for me when trying to install player and other libraries that depended on speaker.
I got it to work by first installing libasound2-dev with:
$ sudo apt-get install libasound2-dev
Then installed speaker with :
sudo npm install --unsafe-perm --verbose -g speaker
and finally installed player with
sudo npm install --unsafe-perm --verbose -g player
Looks good from the console output, but I haven't tried to play a file yet.
FWIW - sudo npm install --unsafe-perm
solved this problem for me as well on Ubuntu 14.04, Node 0.10.24.
After removing /root/.node-gyp, sudo npm install --unsafe-perm --verbose -g solved this problem
I have a similar problem reported here: npm/npm#7764. Is this a problem with npm or node-gyp? No solution solved my problem. When I use --unsafe-perm
I get rid of all error messages, but the installation process runs endlessly.
At node school, similar issue.
$ sudo npm install -g stream-adventure
npm-debug-log
0 info it worked if it ends with ok
1 verbose cli [ 'node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'install',
1 verbose cli '--unsafe-perm',
1 verbose cli '--verbose',
1 verbose cli '-g' ]
2 info using npm@2.7.4
3 info using node@v0.12.2
4 silly cache add args [ '.', null ]
5 verbose cache add spec .
6 silly cache add parsed spec { raw: '.',
6 silly cache add scope: null,
6 silly cache add name: null,
6 silly cache add rawSpec: '.',
6 silly cache add spec: '/Users/seebe',
6 silly cache add type: 'local' }
7 error addLocal Could not install /Users/seebe
8 verbose stack Error: EISDIR, read
8 verbose stack at Error (native)
9 verbose cwd /Users/seebe
10 error Darwin 13.4.0
11 error argv "node" "/usr/local/bin/npm" "install" "--unsafe-perm" "--verbose" "-g"
12 error node v0.12.2
13 error npm v2.7.4
14 error code EISDIR
15 error errno -21
16 error EISDIR, read
17 error If you need help, you may report this error at:
17 error https://github.com/npm/npm/issues
18 verbose exit [ -21, true ]
--unsafe-perm also solved for me, installing on a Gentoo server
fyi about --unsafe-perm
, I found ONE entry in the docs, and NOTHING on the web.
from npm help scripts
If npm was invoked with root privileges, then it will change the uid to the user account or uid specified by the
user
config, which defaults tonobody
. Set theunsafe-perm
flag to run scripts with root privileges.
I guess that "setting the flag" is done with --unsafe-perm
on the command line. If you are logged in as root, it will run the entire install, including downline scripts that are spawned by an npm install
ation, as the root user.
I was having a problem with npm install sails-mongo
failing on this and --unsafe-perm
fixed it.
Note: the reason for using the --unsafe-perm option is that when node-gyp tries to recompile any native libraries it tries to do so as a βnobodyβ user and often fails to get access to certain directories. This causes alarming warnings that look like errorsβ¦ but sometimes are errors. Allowing node-gyp to run as root using this flag avoids this - or rather shows up any real errors instead.
Can it not be made to run as the current user?
--unsafe-perm works
Ach Linux
I had this problem because of using sudo. Works if you first change to the root user :
as normal user $: su
root#: npm install ....
--unsafe-prem does not solve this problem on raspberry pi. Looks like check sum is not valid.
p verb download contents checksum {"node-v0.12.0.tar.gz":"4ec4d32fa16ad1bcdb4229dc57787f26a978bad76abe02980ce17e8cf1a08109"}
gyp verb validating download checksum for node-v0.12.0.tar.gz (4ec4d32fa16ad1bcdb4229dc57787f26a978bad76abe02980ce17e8cf1a08109 == 9700e23af4e9b3643af48cef5f2ad20a1331ff531a12154eef2bfb0bb1682e32)
gyp WARN install got an error, rolling back install
gyp verb command remove [ '0.12.0' ]
gyp verb remove using node-gyp dir: /root/.node-gyp
gyp verb remove removing target version: 0.12.0
gyp verb remove removing development files for version: 0.12.0
gyp ERR! configure error
gyp ERR! stack Error: node-v0.12.0.tar.gz local checksum 4ec4d32fa16ad1bcdb4229dc57787f26a978bad76abe02980ce17e8cf1a08109 not match remote 9700e23af4e9b3643af48cef5f2ad20a1331ff531a12154eef2bfb0bb1682e32
gyp ERR! stack
I have this issue also.
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/0.12.7"
I haven't tried $su yet because the command $sudo npm install
still works with a message "attempting to reinstall using a temporary dev dir". It does take a long time to run though.
I'm also getting this with 0.12.6 on Debian. Attempting to reinstall failed due to a checksum error. With --unsafe-perm
it failed with this:
FATAL ERROR: node::smalloc::Alloc(v8::Handle<v8::Object>, size_t, v8::ExternalArrayType) Out Of Memory
Aborted
On a Raspberry Pi, running as root.
+1
I'm getting same error while installing ishout.js .
npm install ishout.js
gyp WARN EACCES user "root" does not have permission to access the dev dir "/var/root/.node-gyp/0.12.7"
The issue here is that npm normally drops privileges when run as root (e.g. through sudo) before executing node-gyp. As a result, node-gyp may not have access to the the directory containing the node sources. It then logs that warning and tries to soldier on but as often as not, it'll fail.
--unsafe-perm
runs everything as root, including all package pre- and post-install scripts. It probably "fixes" the issue in most cases but I don't really recommend it, it's better to not run npm as root.
Closing, not a bug, just a quirk.
+1
I installed GitBook also being given: gyp WARN EACCES user "root" does not have permission to access the dev dir "/Users/apple/.node-gyp/0.12.7"
Hey,
I had this error on Ubuntu 14.04 from -> sudo npm install -g webpack-dev-server.
Installing compiler fixed it for me:
sudo apt-get install g++
For me it turned out to be a dependency issue,
hope this helps anyone :)
Hi @bnoordhuis I'm getting these warnings when trying to install pm2 on Mac OS 10.10.5.
$ npm --version
2.14.0
$ sudo npm i -g pm2
> fsevents@0.3.8 install /usr/local/lib/node_modules/pm2/node_modules/chokidar/node_modules/fsevents
> node-gyp rebuild
gyp WARN EACCES user "root" does not have permission to access the dev dir "/Users/homedir/.node-gyp/0.12.7"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/pm2/node_modules/chokidar/node_modules/fsevents/.node-gyp"
SOLINK_MODULE(target) Release/.node
CXX(target) Release/obj.target/fse/fsevents.o
SOLINK_MODULE(target) Release/fse.node
/usr/local/bin/pm2 -> /usr/local/lib/node_modules/pm2/bin/pm2
/usr/local/bin/pm2-dev -> /usr/local/lib/node_modules/pm2/bin/pm2-dev
(I've also noticed similar warnings on several other npm install
s recently.)
I understand as you said you don't consider this a bug.
You mentioned that you don't recommend using the --unsafe-perm
option.
Do you have a recommended workaround or course of action we could take to address this?
It isn't a showstopper for me this time around, but as you said --unsafe-perm
(which you don't recommend) "probably 'fixes' the issue in most cases."
What are your thoughts on how to proceed when we encounter the other cases?
Do you have a recommended workaround or course of action we could take to address this?
I'd install it somewhere under my home directory (or a home directory), not site-wide. That way you don't have to run npm as root.
Alternatively, you can take the homebrew approach where you chown everything under /usr/local. It's not the approach I personally would take but if you are on a single-user system (and a Mac usually is), it's probably alright.
I'd install it somewhere under my home directory (or a home directory), not site-wide. That way you don't have to run npm as root.
Alternatively, you can take the homebrew approach where you chown everything under /usr/local. It's not the approach I personally would take but if you are on a single-user system (and a Mac usually is), it's probably alright.
Ok, thanks for the advice. That's helpful.
unsafe_perm worked for me also, however I still don't understand why it's necessary. Not really a fix, just a dirty workaround.
"ls -l /usr/lib/node_modules" (or /usr/local/lib/node_modules) shows that during install the module directory switches from root owner to nobody owner. Safety precaution when compiling native binaries? Don't know. unsafe_perm may well be what is needed, I got it installed by "chmod -R root ..".
On OS X I simply installed xcode but didn't run it, running it for the first time and accepting the license fixed the problem for me.
+1 (Debian 7)
+1 @BaggersIO , thank you, works well sudo npm install --unsafe-perm --verbose -g .....
, in my case for node-inspector :)
For me:
rm -rf /root/.node-gyp/
npm install --unsafe-perm --verbose -g <package-name>
Solved my problem.
And before that, I deleted node_modules
and reinstalled Node.js.
I'm getting the same thing, I just installed NodeJS 4.1.2 from https://nodejs.org/en/ and get this when I run:
sudo npm install sails -global
I'm planning to install Xcode and see if this resolves the problem. I'm a little confused about the versioning of Node. Xcode appears to include version node version 0.12.xx while noedjs.org shows the most recent version of 4.1.2...
@jbburf use npm install --unsafe-perm --verbose -g <package-name>
. In most cases it helps !
Hi everyone,
This guide fixed the problem for me perfectly.
https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md
I will copy the text here for future reference
Install npm
packages globally without sudo on OS X and Linux
npm
installs packages locally within your projects by default. You can also install packages globally (e.g. npm install -g <package>
) (useful for command-line apps). However the downside of this is that you need to be root (or use sudo
) to be able to install globally.
Here is a way to install packages globally for a given user.
1. Create a directory for your global packages
mkdir "${HOME}/.npm-packages"
2. Reference this directory for future usage in your .bashrc
/.zshrc
:
NPM_PACKAGES="${HOME}/.npm-packages"
3. Indicate to npm
where to store your globally installed package. In your $HOME/.npmrc
file add:
prefix=${HOME}/.npm-packages
4. Ensure node
will find them. Add the following to your .bashrc
/.zshrc
:
NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"
5. Ensure you'll find installed binaries and man pages. Add the following to your .bashrc
/.zshrc
:
PATH="$NPM_PACKAGES/bin:$PATH"
# Unset manpath so we can inherit from /etc/manpath via the `manpath`
# command
unset MANPATH # delete if you already modified MANPATH elsewhere in your config
MANPATH="$NPM_PACKAGES/share/man:$(manpath)"
Check out npm-g_nosudo
for doing the above steps automagically
NOTE: If you are running OS X, the .bashrc
file may not yet exist, and the terminal will be obtaining its environment parameters from another file, such as .profile
or .bash_profile
. These files also reside in the user's home folder. In this case, simply adding the following line to them will instruct Terminal to also load the .bashrc
file:
source ~/.bashrc
See also: npm
's documentation on
"Fixing npm
permissions".
Thanks for the explanation about root & nobody; that wasn't clear in the output and it explains the problem. I worked around it by temporarily clowning the (in my case) $HOME/.node-gyp/6.1.0 to nobody, and that let the install/compile proceed.
I agree that running with --unsafe-perm is not advisable, and thus I would not consider that a valid workaround.
It seems like, if it's going to drop privs to "nobody" before continuing, it should probably, before it drops privs, set up a directory that it knows it will be able to write to -- rather than dropping privs and then trying to write to a directory it almost certainly won't be able to write to as "nobody" (a dir under $HOME or /usr/local, in my case).
Could it not "mkdir /tmp/whatever; chown nobody /tmp/whatever" and then proceed with the build using that directory?
Hi there. I've solved those terrible issue for my
# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
with this:
yum groupinstall 'Development Tools'
npm i --unsafe-perm
Hope this helps.
Hey, I got a similar problem as yours, I missed homebridge node yestarday. And I tried to find out all the posssible causes of this issue.
I realize that it was in some way related with some cache problem. But I tested a lot of options,
npm cache clean
and also eliminate the cache files
cd persist
rm *
but at the end the solution was: Edit the BridgeCore.js file, and change the username address of the Bridge node.
vi BridgeCore.js
and change ...
username: "CC:22:3D:E3:CE:F6", change this and reload ...
I suppose that it is because, it is a new id, it means a new bridge. I'm completely sure that it was the problem, because if I undo the username and revert to the original value, it does not work.
It seems this is still not fixed =(
It seems this is still not fixed =(
"Don't install node/npm as root" is the fix. The issue you're seeing (see #454 (comment)) is that npm doesn't like to run as root, if you want to change that then feel free to file an issue with npm (or just search their issues, I'm sure lots of people have complained before): https://github.com/npm/npm/issues
If you're seeing this without having used sudo
then let us know.
I'm not sure why this should be the right solution.
Also see https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
You do not come far without sudo ;-)
Installing node or npm with sudo, sure. But running them as root? Should never be necessary.
Installing node or npm with sudo, sure. But running them as root? Should never be necessary.
Guess what, the problem occurs when I install without sudo (I did not install the package with sudo). The unsafe-perm
flag was the only reliable solution here. ;-)
#454 (comment)
#454 (comment)
#454 (comment)
#454 (comment)
The problem occurs with node 6 and npm 3 on a Debian 8 root server when I try to install sitespeed.io. With a normal npm install -g sitespeed.io
command. Nothing special on my side.
Let me rephrase: if it doesn't work without root, chances are you are doing something wrong.
If npm install -g
in your case means 'install to /usr/local', ask yourself why /usr/local and not your home directory. Node, npm and node-gyp don't mandate that packages are installed system-wide.
If sitespeed.io does, that's a bug in that package, but you are in the wrong bug tracker in that case.
@DanielRuf see the npm help pages, which go into this quite exhaustively: https://docs.npmjs.com/getting-started/fixing-npm-permissions
Note that this is still nothing to do with node-gyp
.
Well, I tried option 2 with the custom path / directory and it did not fix the issue. And I think I also tried option 1 too but npm always reset the directory. Anyway, I got it working with the unsafe-perm
flag.
For anyone else coming across this thread, I recommend just using nvm
, which avoids these issues. Using --unsafe-perm
(running random module install scripts as root) is a pretty terrible idea.
Well, I tried option 2 with the custom path / directory and it did not fix the issue.
A global modules directory that is owned by the user (not by root) is the default for every install method that isn't a Linux package manager, and it works fine.
npm always reset the directory
Unless you're still running with sudo npm
then I've never known it do that. Difficult to debug without more info though.
I recommend just using nvm
1οΈβ£ Install with a line of code
2οΈβ£ Use
$ nvm ls
$ nvm ls-remote
$ nvm install
$ nvm use
$ nvm exec
β Enjoy your life ;-)
The configuration of global packages should be up to the devloper and npm
, which defaults to /usr/local/
for Linux. This package should work with those settings, or at least show a comprehensible error message, instead of runing an infinite loop of attempting to reinstall using temporary dev dir "/usr/lib/node_modules/node-inspector/node_modules/v8-profiler/.node-gyp"
.
@e-beach Have you actually read through the issue or is yours just a pile-up comment?
Try
sudo npm install -g PackageName --allow-root
@Davenchy Nope didn't work.
@Davenchy
Thanks buddy!
This:-
sudo npm install -g PackageName --allow-root
Dis the trick for me on CentOS with cPanel.
Same issue here with angular.
sudo npm i -g @angular/cli --allow-root
Did the trick.
Never had issue with npm and node before and now with clean os I had so many issues in the last two hours I cant believe it.
Issue on Ubuntu 16.04.2 LTS when using
sudo npm install -g @angular/cli --allow-root
This one fixed the errors and installation completed successfully
sudo npm install --unsafe-perm -g @angular/cli
I've taken the liberty of locking this because it's turning into one of those undead issues that attract comments long after its expiry date.
For people coming here through search engines, see #454 (comment).