restart debugger when Node.js application is restarted by nodemon

I'm debugging a remote Node.js application running on localhost with a "Node.js remote debug" configuration (see https://www.jetbrains.com/help/idea/2017.1/running-and-debugging-node-js.html#Node.js_remote_debug). When I use nodemon to automatically restart the application whenever files are changed, the remote debugger looses the connection.

Is there a way to re-attach the debugger when node is restarted? (e.g. something similar to the "restart" option in VSCode (see https://github.com/bdspen/nodemon_vscode)?

5 comments
Comment actions Permalink

No, there is no such feature; please vote for https://youtrack.jetbrains.com/issue/WEB-25672

You can try using Live Edit instead of nodemon to get changes hotswapped without server restart (if it's possible) or restart it. Please see https://blog.jetbrains.com/webstorm/2014/08/live-edit-updates-in-webstorm-9/.
Note that I'd suggest setting 'Update' in Preferences | Build, Execution, Deployment | Debugger | Live Edit to 'Auto in (ms)' and enabling 'Restart if hotswap fails'

0
Comment actions Permalink

This is supported in WebStorm 2021.2: just check the "Reconnect automatically" checkbox of the "Attach to Node.js/Chrome"-typed debug configuration. I think this option should be true by default.

1
Comment actions Permalink

Harmathdenes that is good news
How to find this option in Idea Ultimate?

0
Comment actions Permalink

In exactly the same place - the Attach to Node.js/Chrome run configuration

0
Comment actions Permalink

Elena Pogorelova thanks a lot
Previously I used "npm" and "Jest" templates, now I switched to "Attach to Node.js/Chrome" and it reconnects automatically

1

Please sign in to leave a comment.