How can I run nodemon from within WebStorm?
It looks like the workaround with --exec
isn't necessary anymore, at least when using the newest version of nodemon and Webstorm 7 or 8.
All you have to do is specify your path to nodemon by obtaining its path with running which nodemon
in your console (e.g. /usr/local/bin/nodemon
) under "Node parameters":
@Bela Clark, thanks for confirming.
This is the Windows solution
You can just use the nodemon.cmd instead of node directly like :
Node interpreter : C:\MyPath\To\nodemon.cmdNode parameters : /*Empty for me*/Node WorkingDirectoy : C:\Users\MyUserName\Desktop\DirectoryContainingMyIndex.jsJavaScriptFile : app\index.js /*or just index.js depending on your config*/
and then :
Hope it will help you.
To install nodemon, use the following (if required, use sudo to run the installation with root privileges:
npm install -g nodemon
This will install nodemon globally on your machine.
Then, in your WebStorm Run Configuration, add the following, leaving everything else unchanged:
- Node parameters:
/usr/local/bin/nodemon --exec /usr/local/bin/node
This will instruct the node interpreter to execute the nodemon
script using the following command line: node /usr/local/bin/nodemon --exec /usr/local/bin/node server.js
.
The --exec
part is important, as the execution will fail with the following error:
/usr/local/bin/node /usr/local/bin/nodemon server.js4 Oct 13:56:50 - [nodemon] v0.7.104 Oct 13:56:50 - [nodemon] to restart at any time, enter `rs`4 Oct 13:56:50 - [nodemon] watching: /Users/foo/testexecvp(): No such file or directory4 Oct 13:56:50 - [nodemon] starting `node server.js`4 Oct 13:56:50 - [nodemon] exception in nodemon killing nodeError: spawn ENOENT at errnoException (child_process.js:980:11) at Process.ChildProcess._handle.onexit (child_process.js:771:34)
The error seems to be caused by WebStorm not seeing the node
executable on its path.
The fix for this is to specify the location to the node
executable using the --exec /usr/local/bin/node
parameter.
Using these settings, nodemon works fine when run from a WebStorm Run Configuration.
The same trick might have to be used with some of the tools similar to nodemon, e.g. node-supervisor.