2

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
node-dev@0.2.9 /usr/local/share/npm/lib/node_modules/node-dev
└── growl@1.6.1

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

/usr/local/share/npm/lib
└─┬ node-dev@0.2.9
  └── growl@1.6.1

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.

Community
  • 1
  • 1
ahsteele
  • 26,243
  • 28
  • 134
  • 248

1 Answers1

1

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

Joe McBride
  • 3,789
  • 2
  • 34
  • 38
  • Sorry for this post dangling. The holiday got the better of me and pulled me away from all development. Unfortunately, I think my issue has to do w/ the actual node-dev install. As indicated in my question I can't get it to run from terminal. The linked post indicates that nodemon should just work after install. I'd imagine node-dev to work the same way and in fact after trying the first part of the post received the same error when trying to run nodemon. Because of this I edited and refocused the question on my npm global install & will circle back around to sublime once terminal is working. – ahsteele Nov 27 '12 at 04:47