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

Warning "root" does not have permission to access the dev dir #454

Closed
tjwebb opened this issue Jun 7, 2014 · 66 comments
Closed

Warning "root" does not have permission to access the dev dir #454

tjwebb opened this issue Jun 7, 2014 · 66 comments

Comments

@tjwebb
Copy link

tjwebb commented Jun 7, 2014

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?

@tjwebb tjwebb changed the title "root" does not have permission to access the dev dir Warning "root" does not have permission to access the dev dir Jun 7, 2014
@ferdi24
Copy link

ferdi24 commented Jun 23, 2014

[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...!!!

@mhintz
Copy link

mhintz commented Jul 7, 2014

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 rebuild

gyp 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!

@mhintz
Copy link

mhintz commented Jul 7, 2014

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...

@kulicuu
Copy link

kulicuu commented Jul 7, 2014

If I remember correctly, set unsafe-perm to true when running as sudo is a fix it's obstructing.

@djensen47
Copy link

I'm also seeing this on SmartOS/illumos/Solaris

@tomascharad
Copy link

+1
gyp WARN EACCES user "root" does not have permission to access the dev dir "/Users/XXX/.node-gyp/0.10.32"

@tjwebb
Copy link
Author

tjwebb commented Sep 28, 2014

Doesn't look like the project maintainer cares much about this issue

@tomascharad
Copy link

I solved it by using chown on the .node-gyp folder and cleaning cache if I remember correctly.

@BaggersIO
Copy link

Same problem here. Using Ubuntu 14.04. chown on the node-gyp folder did not fix the issue :(

@BaggersIO
Copy link

Solved it be adding --unsafe-perm.

In my case with sails:

sudo npm install --unsafe-perm --verbose -g sails

Works well!

@herrdu
Copy link

herrdu commented Oct 18, 2014

why should I set 'unsafe-perm ' =true ,what's the meaning of "unsafe-perm"?

@herrdu
Copy link

herrdu commented Oct 18, 2014

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 ?

@herrdu
Copy link

herrdu commented Oct 18, 2014

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!!!

@Jakobud
Copy link

Jakobud commented Oct 29, 2014

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.

@fooooorrest
Copy link

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.

@apollolm
Copy link

apollolm commented Jan 7, 2015

FWIW - sudo npm install --unsafe-perm solved this problem for me as well on Ubuntu 14.04, Node 0.10.24.

@y-rok
Copy link

y-rok commented Mar 25, 2015

After removing /root/.node-gyp, sudo npm install --unsafe-perm --verbose -g solved this problem

@donaldpipowitch
Copy link

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.

@cliveb
Copy link

cliveb commented Apr 8, 2015

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 ]

@ranisalt
Copy link

--unsafe-perm also solved for me, installing on a Gentoo server

@DanielRuf
Copy link

It seems this is still not fixed =(

@gibfahn
Copy link
Member

gibfahn commented Jul 16, 2017

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.

@DanielRuf
Copy link

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 ;-)

@bnoordhuis
Copy link
Member

Installing node or npm with sudo, sure. But running them as root? Should never be necessary.

@DanielRuf
Copy link

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. ;-)

@DanielRuf
Copy link

#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.

@bnoordhuis
Copy link
Member

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.

@gibfahn
Copy link
Member

gibfahn commented Jul 17, 2017

@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.

@DanielRuf
Copy link

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.

@gibfahn
Copy link
Member

gibfahn commented Jul 17, 2017

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.

@tbaltrushaitis
Copy link

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 ;-)

@elliott-beach
Copy link

elliott-beach commented Jul 22, 2017

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".

@bnoordhuis
Copy link
Member

@e-beach Have you actually read through the issue or is yours just a pile-up comment?

@Davenchy
Copy link

Try
sudo npm install -g PackageName --allow-root

@JSAbrahams
Copy link

@Davenchy Nope didn't work.

@jasmeetdd
Copy link

@Davenchy
Thanks buddy!
This:-
sudo npm install -g PackageName --allow-root
Dis the trick for me on CentOS with cPanel.

@Extarys
Copy link

Extarys commented Sep 19, 2017

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.

@manmohanbishnoi
Copy link

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

@nodejs nodejs locked and limited conversation to collaborators Sep 21, 2017
@bnoordhuis
Copy link
Member

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).

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