microsoft/nodejstools

Allow using nodemon with Visual Studio

rjamesnw opened this issue · 6 comments

I noticed other posts on the issue, which are now quite old. Is it still the stance that this will not be supported at all? I'm trying to get a seemingly simple thing to work, which is to not have the Visual Studio (2017) debugger detach when nodemon restarts NodeJS. I imagine it happens because the NodeJS process terminates and restarts (but a port is being used, so it may just be the connection is lost). Is there no way at all to have VS auto-reconnect to the port? Is it really that big of a problem to support this? If not, I may be forced to switch to VS Code (I'm sure I'm not the first or the last if this persists). I work for a large company and we are switching over to doing a lot with NodeJS. If we convert projects over to VS Code we will just use that and stop using VS, which seems like a bad business choice for MS.

@rjamesnw Thanks for your feedback! We think this might already be possible, but we're confirming before we post potentially incorrect details.

Nope, turns out it doesn't work yet. It sounds straightforward though. @rakatyal, we probably just have to set these parameters here.

Yeah, I already tested also before posting. ;) If this gets in it would significantly improve the development process by not having to build and run over and over. There is way too much overhead when having to stop and restart using VS.

@rjamesnw: Thanks for reporting the issue. I am in the process of figuring out what it would take on the VS side to support the "restart" option. Out of curiosity, can you tell me how are you currently integrating "nodemon" with Node Project System and launching it?

There are two options:

  1. Use NPM to save a local dependency on nodemon and use NodeJS to run the node_modules\nodemon\bin\nodemon.js file. I put the path to the JS file into the “Node.exe options” project setting.

  2. Install globally and run the nodemon.cmd command. I put the path to the command file into the “Node.exe path” project setting.

Both will launch it, but it seems option 1 works best because Visual Studio can attach to the NodeJS process, but since a debug port is being used I'm not sure how much that should really matter. It also keeps a dependency that can be restored when others download the project (otherwise the global option can fail if not set up).

Both options will accept the main entry file that VS passes as a parameter.

Be mindful of the --inspect=port options, which is the new way. The old way is using the --debug=port options.

Any updates? I just tried out of curiosity and it still doesn't work. It would be great to have nodemon restart the NodeJS server automatically; would save a lot of overhead as Visual Studio spends a lot of time trying to build and launch for every simple change.