3

os: debian 7

node.js is installed in the defalut folder .

root@10-4-4-159:/usr/local# npm install forever -g

npm ERR! Error: setuid user id does not exist

npm ERR! at /usr/local/lib/node_modules/npm/node_modules/uid-number/uid-number.js:44:16

npm ERR! at ChildProcess.exithandler (child_process.js:635:7)

npm ERR! at ChildProcess.EventEmitter.emit (events.js:98:17)

npm ERR! at maybeClose (child_process.js:735:16)

npm ERR! at Process.ChildProcess._handle.onexit (child_process.js:802:5)

npm ERR! If you need help, you may report this log at:

npm ERR! http://github.com/isaacs/npm/issues

npm ERR! or email it to:

npm ERR!

npm ERR! System Linux 3.2.0-4-amd64

npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "forever" "-g"

npm ERR! cwd /usr/local

npm ERR! node -v v0.10.21

npm ERR! npm -v 1.3.11

npm ERR!

npm ERR! Additional logging details can be found in:

npm ERR! /usr/local/npm-debug.log

npm ERR! not ok code 0

sunchuo
  • 53
  • 2
  • 5

3 Answers3

8

Work around for this issue:

Open the file below in your editor:

/usr/local/lib/node_modules/npm/node_modules/uid-number/uid-number.js

Goto line 11, then replace uidSupport = process.getuid && process.setuid with uidSupport = false

damphat
  • 18,246
  • 8
  • 45
  • 59
  • For NAS-boxes (e.g. entware-based QNAP NAS extensions), the path of the file to be fixed is `/opt/lib/node_modules/npm/node_modules/uid-number/uid-number.js`. – themole Jul 16 '17 at 22:48
  • thanks for posting this, i'd give more upvotes if i could. – C4 - Travis Jul 12 '19 at 18:45
2

For those who want just a quick shell oneliner to fix the issue.
Linux:
sed -i'' -r 's/^( +, uidSupport = ).+$/\1false/' /path/to/uid-number.js

FreeBSD:
sed -i'' -e -E 's/^( +, uidSupport = ).+$/\1false/' /path/to/uid-number.js

1

Root cause: npm assumes nobody as user while calling process.getuid, which fails if your system does not have an user called nobody.

Solution: create a new user called nobody and try again! sudo adduser --no-create-home --shell /dev/null --disabled-password --disabled-login --gecos '' nobody

Adarsha
  • 2,267
  • 22
  • 29