node: command not found [duplicate]

I am in the process of setting up node.js in order to work with a framework like Meteor, Derby, or Ember, but am running into some problems early on. Following these instructions (http://www.nodebeginner.org), I installed node, created a simple helloworld.js file, then ran this command in the terminal:

node path/to/file/helloworld.js

but I get the following error:

-bash: node: command not found

I've tried navigating to the directory, then simply running:

node helloworld.js

but get the same error. I am completely new to node.js and am at a loss.

Running OS X 10.7.5 and the latest version of node.


Solution 1:

The problem is that your PATH does not include the location of the node executable.

You can likely run node as "/usr/local/bin/node".

You can add that location to your path by running the following command to add a single line to your bashrc file:

echo 'export PATH=$PATH:/usr/local/bin' >> $HOME/.bashrc
source $HOME/.bashrc