Globally installed node-dev causes error "command not found"

4k Views Asked by At

So that I don't have to keep restarting node.js during development I'm trying to use node-dev. Unfortunately, when I try to run node-dev from terminal I receive the error:

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

I have globally installed node-dev via the npm install node-dev -g command. The output from this command is:

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]

To be sure node-dev is installed globally I've run npm ls -g which returns:

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

Some other posts have indicated that my globally installed npm modules should be in the /usr/local/lib/node_modules folder instead of /usr/local/share/npm/lib/. I can't tell if this is for older versions of npm or something that actually matters.

I'm new to both Mac OS X and Node development so it wouldn't surprise me that I was overlooking something trivial. What haven't I done which is causing me to get a "command not found" error when trying to utilize node-dev? Is there some sort of $PATH environment issue I'm overlooking?

One note I don't have Growl installed but the node-dev documentation indicated it was optional.

1

There are 1 best solutions below

1
On

I think this could be your issue, and here's a walk-through to fixing it. It's specifically for WebStorm & Mocha, but seems like it could be related. I think you may need to setup an alias.

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