Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run nodemon from within WebStorm?

I would like to use nodemon from within the WebStorm IDE (version 7). Nodemon watches one or more files in my source folder and restarts the node process (an Express server in this case), when one of the source files changes.

How do I configure WebStorm to use nodemon in a Run Configuration, so that the node process is automatically restarted?

Without nodemon, I use the following configuration in WebStorm, but have to restart the node process whenever I change something in the source file:

  • Node interpreter: /usr/local/bin/node
  • Working directory: /Users/foo/test
  • JavaScript file: server.js

This results in a Run Configuration that runs node server.js in the specified directory.

From command line, I can use the following command to use nodemon to watch for file changes: nodemon server.js in the project directory.

How do I need to change the WebStorm configuration so that it also uses nodemon?

like image 633
nwinkler Avatar asked Oct 04 '13 12:10

nwinkler


People also ask

How do I run Nodemon locally?

Local Installation You can also install nodemon locally. When performing a local installation, you can install nodemon as a dev dependency with --save-dev (or --dev ). Install nodemon locally with npm : npm install nodemon --save-dev.

How do I run code in WebStorm?

To run a script, open it in the editor or select it in the Project tool window, and then select Run <script file name> from the context menu. WebStorm creates a temporary run/debug configuration of the type Node. js. To run a test, click the gutter icon next to it or press Ctrl+Shift+F10 .


2 Answers

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":

Webstorm with nodemon

@Bela Clark, thanks for confirming.

like image 192
bernhardw Avatar answered Oct 10 '22 13:10

bernhardw


This is the Windows solution

You can just use the nodemon.cmd instead of node directly like :

Node interpreter : C:\MyPath\To\nodemon.cmd Node parameters : /*Empty for me*/ Node WorkingDirectoy : C:\Users\MyUserName\Desktop\DirectoryContainingMyIndex.js JavaScriptFile : app\index.js /*or just index.js depending on your config*/ 

and then :

enter image description here

Hope it will help you.

like image 25
RPDeshaies Avatar answered Oct 10 '22 13:10

RPDeshaies