2012-11-17 127 views
2

因此,我不必保留restarting node.js during development我正在尝试使用node-dev。不幸的是,当我尝试从终端上运行的节点-dev的我收到的错误:全局安装的node-dev会导致错误“找不到命令”

$ node-dev server.js
-bash: node-dev: command not found

我已经安装在全球通过npm install node-dev -g命令节-dev的。此命令的输出是:

npm http GET https://registry.npmjs.org/node-dev 
npm http 304 https://registry.npmjs.org/node-dev 
npm http GET https://registry.npmjs.org/growl 
npm http 304 https://registry.npmjs.org/growl 
/usr/local/share/npm/bin/node-dev -> /usr/local/share/npm/lib/node_modules/node-dev/node-dev 
[email protected] /usr/local/share/npm/lib/node_modules/node-dev 
└── [email protected] 

可以肯定的节点开发在全球范围内安装我已经运行npm ls -g返回:

/usr/local/share/npm/lib 
└─┬ [email protected] 
    └── [email protected] 

其他有些岗位指出,我在全球安装的NPM模块应在/usr/local/lib/node_modules文件夹中而不是/usr/local/share/npm/lib/。我不知道这是否适用于老版本的npm或者其他重要的东西。

我是Mac OS X和Node开发人员的新手,所以我不会感到惊讶,因为我忽略了一些微不足道的东西。当我试图利用node-dev时,我没有做过什么,导致我得到“command not found”错误?是否有某种我忽略的$ PATH环境问题?

一注意我没有安装Growl,但node-dev文档表明它是可选的。

+0

Tagged:'sublimetext2':D –

回答

1

我认为这可能是你的问题,并且here's a walk-through来解决它。它专门用于摩卡咖啡,但似乎可能是相关的。我想你可能需要设置一个别名。

env: node: No such file or directory

Reason for this is that when running GUI applications under MacOSX, the environment variables are not the same as those when you run a from a terminal. In particular, node for instance is not on the path. To overcome this issue, you can either launch WebStorm from the terminal (yuck!) or solve it. Fortunately this isn’t as hard as it once was. Here’s a Tip on our forum for RubyMine but it applies to all IDE’s including WebStorm. In essence, its creating an environment.plist file inside ~/.MacOSX which contains your full path. Mine is here if you want to download it. Make sure you reboot your machine after doing this step.

Setting up an alias

Everything should be working now, but instead of having to type this in each time, lets set up an alias for it in WebStorm. Click on Preferences (CMD+, under MacOSX) and type in Command to get to the command line tools. Click on the + button to create a new entry and confirm the dialog box to create a new custom framework.

enter image description here

+0

抱歉,此帖悬空。假期越来越好,把我从所有的发展中拉出来。不幸的是,我认为我的问题必须在实际的node-dev安装上进行。正如我的问题所示,我无法从终端运行。链接的帖子指出nodemon应该在安装后才工作。我想象node-dev以同样的方式工作,事实上,在尝试运行nodemon时,尝试第一部分帖子收到同样的错误。因此,我编辑并重新将问题重点放在了我的npm全局安装上,一旦终端开始工作,它将围绕着升华。 – ahsteele