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:
/usr/local/bin/node
/Users/foo/test
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?
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.
You may NOT have nodemon
exists from which nodemon
command, then you should have it in your package.json ie nodemon
be installed at :project_dir/node_modules/.bin/nodemon
Then from Webstorm 's run/debug config, set Node parameters
to be
:path_to_project_dir/node_modules/.bin/nodemon
You should save the debug/run config to file so your teammates can also easily debug/run your nodejs app like you
This will save the config into some .xml file, sample as below
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="index.js" type="NodeJSConfigurationType" path-to-node="$USER_HOME$/.nvm/versions/node/v19.4.0/bin/node" nameIsGenerated="true" node-parameters="../node_modules/.bin/nodemon" path-to-js-file="index.js" working-dir="$PROJECT_DIR$/nodejs27/node27_sequelize_apiapp/src">
<method v="2" />
</configuration>
</component>