isaacs/npm — Issue #2168: "make install" fails both with sudo and without
Author: llimllib
Created: 2012-02-16 21:04:23+00:00
State: open

Using tag v1.0.106 (which I need to install because tilemill requires node 0.4.x), I can't install with or without sudo because root doesn't have access to ~ and the my user doesn't have access to /usr/lib.

(Root doesn't have access to ~ because it's an NFS mount, and more or less, my sysadmin has set it up that way and it's out of my control.)

If I "make install" (no sudo) I get:

$ make install
! [ -d .git ] || git submodule update --init --recursive
scripts/doc-build.sh doc/api/edit.md man/man3/edit.3
make[1]: Entering directory `/tmp/npm-install/npm'
node cli.js install https://github.com/isaacs/ronnjs/tarball/master
ronn@0.3.7 ./node_modules/ronn
└── opts@1.2.2
make[1]: Leaving directory `/tmp/npm-install/npm'
scripts/doc-build.sh doc/api/install.md man/man3/install.3
#
node cli.js install -g -f
npm ERR! error installing npm@1.0.106 Error: EACCES, Permission denied '../lib/node_modules/npm/bin/npm-cli.js'
npm ERR! error rolling back npm@1.0.106 Error: ENOTEMPTY, Directory not empty '/usr/lib/node_modules/npm/node_modules'
npm ERR! Error: EACCES, Permission denied '../lib/node_modules/npm/bin/npm-cli.js'
npm ERR! Report this *entire* log at:
npm ERR!
npm ERR! or email it to:
npm ERR!
npm ERR!
npm ERR! System Linux 2.6.38-11-server
npm ERR! command "node" "/tmp/npm-install/npm/cli.js" "install" "-g" "-f"
npm ERR! cwd /tmp/npm-install/npm
npm ERR! node -v v0.4.12
npm ERR! npm -v 1.0.106
npm ERR! path ../lib/node_modules/npm/bin/npm-cli.js
npm ERR! code EACCES
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /tmp/npm-install/npm/npm-debug.log
npm not ok
make: *** [install] Error 1

If I "sudo make install":

$ sudo make install
! [ -d .git ] || git submodule update --init --recursive
scripts/doc-build.sh doc/api/edit.md man/man3/edit.3
make[1]: Entering directory `/tmp/npm-install/npm'
node cli.js install https://github.com/isaacs/ronnjs/tarball/master
npm ERR! Error: EACCES, Permission denied '/Users/bill/.npm/ronn/0.3.7/package.tgz'
npm ERR! Report this *entire* log at:
npm ERR!
npm ERR! or email it to:
npm ERR!
npm ERR!
npm ERR! System Linux 2.6.38-11-server
npm ERR! command "node" "/tmp/npm-install/npm/cli.js" "install" "https://github.com/isaacs/ronnjs/tarball/master"
npm ERR! cwd /tmp/npm-install/npm
npm ERR! node -v v0.4.12
npm ERR! npm -v 1.0.106
npm ERR! path /Users/bill/.npm/ronn/0.3.7/package.tgz
npm ERR! code EACCES
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /tmp/npm-install/npm/npm-debug.log
npm not ok
make[1]: *** [node_modules/ronn] Error 1
make[1]: Leaving directory `/tmp/npm-install/npm'
make: *** [man/man3/edit.3] Error 2

any ideas? Is there a way to convince npm to install without needing access to ~ or without needing to run as sudo?

(I tried making a user-owned /usr/lib/node_modules and installing without sudo, but this fails in a rather strange fashion:

If I try to create a user-owned node_modules directory:

$ sudo mkdir /usr/lib/node_modules && sudo chown bill /usr/lib/node_modules
$ make install
! [ -d .git ] || git submodule update --init --recursive
scripts/doc-build.sh doc/api/edit.md man/man3/edit.3
make[1]: Entering directory `/tmp/npm-install/npm'
node cli.js install https://github.com/isaacs/ronnjs/tarball/master
ronn@0.3.7 ./node_modules/ronn
└── opts@1.2.2
make[1]: Leaving directory `/tmp/npm-install/npm'
scripts/doc-build.sh doc/api/install.md man/man3/install.3
#
node cli.js install -g -f
npm ERR! error installing npm@1.0.106 Error: EACCES, Permission denied '../lib/node_modules/npm/bin/npm-cli.js'
npm ERR! error rolling back npm@1.0.106 Error: ENOTEMPTY, Directory not empty '/usr/lib/node_modules/npm/node_modules'
npm ERR! Error: EACCES, Permission denied '../lib/node_modules/npm/bin/npm-cli.js'
npm ERR! Report this *entire* log at:
npm ERR!
npm ERR! or email it to:
npm ERR!
npm ERR!
npm ERR! System Linux 2.6.38-11-server
npm ERR! command "node" "/tmp/npm-install/npm/cli.js" "install" "-g" "-f"
npm ERR! cwd /tmp/npm-install/npm
npm ERR! node -v v0.4.12
npm ERR! npm -v 1.0.106
npm ERR! path ../lib/node_modules/npm/bin/npm-cli.js
npm ERR! code EACCES
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /tmp/npm-install/npm/npm-debug.log
npm not ok
make: *** [install] Error 1

There's no reason npm should be getting a permission denied on that dir, though it could have something to do with the fact that /usr/lib/node_modules/npm/bin doesn't exist. Just to show that permissions as me works:

$ mkdir /usr/lib/node_modules/npm/bin && touch /usr/lib/node_modules/npm/bin/npm-cli.js

)

Any ideas for how I can get npm installed?