AshHeskes AshHeskes - 5 months ago 10
Node.js Question

Error installing NPM for node.js

I'm trying to install

npm
on ubuntu 11.04 using the "git all the way" method found in this gist

I keep getting this error after running
sudo make install
on
npm


$ sudo make install
! [ -d .git ] || git submodule update --init --recursive
node cli.js install -g -f
bash: node: command not found
make: *** [install] Error 127


I know this is something wrong with
bash
, but I'm not very good with bash.

EDIT

running the
node
command in the terminal brings up the
node
shell
as expected

Answer

Your problem is that when you sudo, you are not sourcing the same bashrc file (or whatever is setting your PATH and/or NODE_PATH), and so the system cannot find node.

I would guess that sudo node won't work.

You need to export your NODE_PATH as @Ken suggested, WHILE SUDOING:

sudo PATH=/path/to/node/bin/dir:$PATH make install

EDIT: to use PATH as worked in comments below