1

I've got a raspberry pi that I'm running node on. I followed this guide http://joshondesign.com/2013/10/23/noderpi to install node.

When I setup the NODE_JS_HOME, I can run node from the command line, but not sudo node, and I need to be sudo to access GPIO.

I also seem to need to re-enter the NODE_JS_HOME in my .bash_profile every time I open a new terminal window. I'm hoping that I can set node globally and be able to run sudo node form the command line, right from start-up.

3
  • what is the error when running sudo node? command not found, or not allowed to be sudo? – mcalex May 27 '14 at 5:34
  • running sudo node' returns sudo: node: command not found`, I've now got node loading by default as per @fede.evol – pedalpete May 27 '14 at 6:57
  • you should be able to run su -c 'node' or sudo /path/to/node. try them – mcalex May 27 '14 at 7:06
1

Try setting the NODE_JS_HOME variable in your /etc/profile file. That file contains system wide settings that will therefore be applied to every shell execution.

3
  • Thanks fede, I now can load node automatically, but I still can't load using sudo node, I get the error sudo: node: command not found – pedalpete May 27 '14 at 6:57
  • I guess you're missing the PATH part aswell. In the doc you refeer it shows to put also the PATH (PATH=$PATH:$NODE_JS_HOME/bin). You should put also that in /etc/profile (of course after the NODE_JS_HOME definition) – fede.evol May 28 '14 at 9:48
  • I have both the definition and the PATH in my /etc/profile, but no luck running node via sudo – pedalpete May 29 '14 at 5:42
0

I ended up uninstalling node and re-installing via

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

After that sudo node ran perfectly, without having to set-up any profiles

0

To get sudo to work on normal linux, I had to make these links:

  ln -s /usr/local/bin/node /usr/bin/node
  ln -s /usr/local/lib/node /usr/lib/node
  ln -s /usr/local/bin/npm /usr/bin/npm
  ln -s /usr/local/bin/node-waf /usr/bin/node-waf

Not sure if they'll make it work in raspberry pi too, but its probably worth a try.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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