2

Following these directions to install nodeJs and socketIO on a Raspberry Pi

http://www.bartbania.com/index.php/build-your-own-google-tv-using-raspberrypi/

When I try running

npm install

get the following error

Please try running this command again as root/Administrator.

Prefixing with 'sudo' simply gives a 'command not found'

Anyone know how to resolve this?

I tried to recursively change the owner of the files in my /usr/local folder to the current user:

sudo chown -R $USER /usr/local

But it makes no difference

1
  • sudo /opt/node/bin/npm install Yes! Commented Nov 27, 2013 at 17:21

2 Answers 2

1

Looking over the link you provided, the likely problem is that the environment variable JS_HOME is set for the pi user (or whatever user you installed node as) but not for root.

The simpleset way to fix this is to use the full path to the npm commnad. To determine what the proper path is type

which npm 

in the terminal. this will return the full path. Then you can do

sudo <full path to npm> install...

Since the above fixed the problem you may not have set the path correctly in /etc/profile.

sudo nano /etc/profile

Add the following lines to the file before the ‘export’ command.

NODE_JS_HOME="/opt/node"
PATH="$PATH:$NODE_JS_HOME/bin"
export PATH

You may need to logout for the above to take effect. You can verify that it works by using the following command:

echo $PATH

If you correct that you won't need to use the full path.

You probably also want to reverse the change of ownership for usr/local as well by typing.

sudo chown -R root /usr/local
-1

Try reinstalling pre-compiled node package:

wget http://node-arm.herokuapp.com/node_latest_armhf.deb
sudo dpkg -i node_latest_armhf.deb

and run npm again

1
  • 1
    The problem is not with the install, but with his $PATH variable. Commented Nov 27, 2013 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.