Skip to content
This repository was archived by the owner on Aug 11, 2022. It is now read-only.

Error: EACCES, mkdir '/root/.npm' problem #2425

Closed
irixruin opened this issue May 7, 2012 · 8 comments
Closed

Error: EACCES, mkdir '/root/.npm' problem #2425

irixruin opened this issue May 7, 2012 · 8 comments

Comments

@irixruin
Copy link

irixruin commented May 7, 2012

when I try to use npm to install mongodb using

npm install -g mongodb

it outputs as follow:

npm http GET https://registry.npmjs.org/mongodb
npm http 200 https://registry.npmjs.org/mongodb
npm http GET https://registry.npmjs.org/mongodb/-/mongodb-1.0.0.tgz
npm http 200 https://registry.npmjs.org/mongodb/-/mongodb-1.0.0.tgz

npm ERR! Error: EACCES, mkdir '/root/.npm'
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.
npm ERR! 
npm ERR! System Linux 3.2.0-23-generic
npm ERR! command "node" "/opt/node/0.6.17/bin/npm" "-g" "install" "mongodb"
npm ERR! cwd /pr/node
npm ERR! node -v v0.6.17
npm ERR! npm -v 1.1.21
npm ERR! path /root/.npm
npm ERR! code EACCES
npm ERR! message EACCES, mkdir '/root/.npm'
npm ERR! errno {}

npm ERR! Error: EACCES, open 'npm-debug.log'
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.
npm ERR! 
npm ERR! System Linux 3.2.0-23-generic
npm ERR! command "node" "/opt/node/0.6.17/bin/npm" "-g" "install" "mongodb"
npm ERR! cwd /pr/node
npm ERR! node -v v0.6.17
npm ERR! npm -v 1.1.21
npm ERR! path npm-debug.log
npm ERR! code EACCES
npm ERR! message EACCES, open 'npm-debug.log'
npm ERR! errno {}
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /pr/node/npm-debug.log
npm not ok

My system is ubuntu 12.04 LTS x86_64 and I running the npm as root user.
Not sure wether it matters, I install node from source to /opt/node/0.6.17/ and added the path in $PATH
I tried re installing node v0.6.17 but the same result.

@isaacs
Copy link
Contributor

isaacs commented May 7, 2012

So, why doesn't root have write access to ~root?

Solve that problem, and it will work.

@irixruin
Copy link
Author

irixruin commented May 7, 2012

I purplexed too. I can freely access my /root without any problem.

@isaacs
Copy link
Contributor

isaacs commented May 7, 2012

Try this:

$ node
> require('fs').mkdirSync('/root/.npm', 0755)

@irixruin
Copy link
Author

irixruin commented May 8, 2012

It's also permission deny.. Orz

Error: EACCES, permission denied '/root/.npm'
at Object.mkdirSync (fs.js:383:18)
at repl:1:16
at REPLServer.eval (repl.js:80:21)
at Interface.<anonymous> (repl.js:182:12)
at Interface.emit (events.js:67:17)
at Interface._onLine (readline.js:162:10)
at Interface._line (readline.js:426:8)
at Interface._ttyWrite (readline.js:603:14)
at ReadStream.<anonymous> (readline.js:82:12)
at ReadStream.emit (events.js:88:20)

@isaacs
Copy link
Contributor

isaacs commented Jun 17, 2012

What does whoami return?

Is it possible that /root is a read-only file system mount or something? (Though, then it shoudl be returning EPERM, not EACCES.)

@jsepia
Copy link

jsepia commented Jun 18, 2012

I had the same problem (using Fedora 16), and solved it by running chmod -R g+w . while in my /root directory. The -R may have been overkill though... but whatever.

Anyway, maybe npm was running as the root group rather than the root user?

@isaacs
Copy link
Contributor

isaacs commented Jun 18, 2012

Oh, probably because you were running as root, it's setuid'ing to the "nobody" user. You can run with --unsafe-perm (or npm config set unsafe-perm true to make it stick) to go ahead and let it remain as root.

@isaacs isaacs closed this as completed Jun 18, 2012
@jsepia
Copy link

jsepia commented Jun 20, 2012

That makes sense.

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

3 participants