48

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.

4

1 回答 1

51

问题是您的 PATH 不包括节点可执行文件的位置。

您可以将节点运行为“ /usr/local/bin/node”。

您可以通过运行以下命令将单行添加到 bashrc 文件来将该位置添加到路径中:

echo 'export PATH=$PATH:/usr/local/bin' >> $HOME/.bashrc
source $HOME/.bashrc
于 2012-11-27T22:04:58.927 回答