Estoy intentando instalar npm mediante un script de shell en mac 10.6.4 y sudo no parece funcionar porque el shell falla al intentar acceder a /usr/lib y crear documentos en ese directorio. ¿Lo que está mal?
fred:echowaves fred$ sudo curl http://npmjs.org/install.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3927 100 3927 0 0 3702 0 0:00:01 0:00:01 --:--:-- 6975
fetching: http://registry.npmjs.org/npm/-/npm-1.0.22.tgz
0.4.10
1.0.22
prefix=/usr
This script will find and eliminate any shims, symbolic
links, and other cruft that was installed by npm 0.x.
Is this OK? enter 'yes' or 'no'
es
Is this OK? enter 'yes' or 'no'
yes
All clean!
! [ -d .git ] || git submodule update --init --recursive
node cli.js cache clean
node cli.js rm npm -g -f --loglevel error
node cli.js install -g -f
npm ERR! Could not create /usr/lib/node_modules/___npm.npm
npm ERR! error installing [email protected] Error: EACCES, Permission denied '/usr/lib/node_modules/___npm.npm'
npm ERR! Error: EACCES, Permission denied '/usr/lib/node_modules/___npm.npm'
npm ERR!
npm ERR! Please use 'sudo' or log in as root to run this command.
npm ERR!
npm ERR! sudo npm "install" "-g" "-f"
npm ERR!
npm ERR! or set the 'unsafe-perm' config var to true.
npm ERR!
npm ERR! npm config set unsafe-perm true
npm ERR!
npm ERR! System Darwin 11.0.0
npm ERR! command "node" "/private/var/folders/lf/7q2cr83j2nvdvp266pg6p0180000gn/T/npm.64068/package/cli.js" "install" "-g" "-f"
npm ERR! cwd /private/var/folders/lf/7q2cr83j2nvdvp266pg6p0180000gn/T/npm.64068/package
npm ERR! node -v v0.4.10
npm ERR! npm -v 1.0.22
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /private/var/folders/lf/7q2cr83j2nvdvp266pg6p0180000gn/T/npm.64068/package/npm-debug.log
npm not ok
make: *** [install] Error 13
npm ERR! Could not create /usr/lib/node_modules/___npm.npm
npm ERR! error installing [email protected] Error: EACCES, Permission denied '/usr/lib/node_modules/___npm.npm'
npm ERR! Error: EACCES, Permission denied '/usr/lib/node_modules/___npm.npm'
npm ERR!
npm ERR! Please use 'sudo' or log in as root to run this command.
npm ERR!
npm ERR! sudo npm "install" "-gf"
npm ERR!
npm ERR! or set the 'unsafe-perm' config var to true.
npm ERR!
npm ERR! npm config set unsafe-perm true
npm ERR!
npm ERR! System Darwin 11.0.0
npm ERR! command "/usr/bin/node" "/private/var/folders/lf/7q2cr83j2nvdvp266pg6p0180000gn/T/npm.64068/package/cli.js" "install" "-gf"
npm ERR! cwd /private/var/folders/lf/7q2cr83j2nvdvp266pg6p0180000gn/T/npm.64068/package
npm ERR! node -v v0.4.10
npm ERR! npm -v 1.0.22
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /private/var/folders/lf/7q2cr83j2nvdvp266pg6p0180000gn/T/npm.64068/package/npm-debug.log
npm not ok
It failed
fred:echowaves fred$
Respuesta1
Parece que estás ejecutando la primera parte del comando ( sudo curl http://npmjs.org/install.sh
) como root, pero luego lo estás canalizando a sh con los permisos habituales de tu cuenta. Intente dividirlo en dos comandos:
sudo curl -O http://npmjs.org/install.sh
sudo ./install.sh
Respuesta2
Sudo sólo afecta al curl. Debes cambiar a root antes de ejecutar el comando. Tipo:
$ sudo su
root$ curl http://npmjs.org/install.sh | sh
root$ exit