7

I was working with Node on Visual Studio Professional 13, and I soon realized that restarting my server for every change in code was becoming a hassle.

So I did some research and discovered that most people used the nodemon to automatically refresh their server. Although the tutorials online used command line to install and run their server with nodemon when I used VS's interface to generate my express project and download nodemon.

My problem is that when I run my server, the server doesnt restart when I update my code. My question is how can run my server through nodemon if I am coding my project using VS

this link also shows people with the same question as me, but the solution in it isn't that clear https://nodejstools.codeplex.com/workitem/545

AmitS
  • 170
  • 1
  • 12
  • In the end I stopped using VS to start the server and used command line to start the server through nodemon. But if anyone knows how to use VS feel free to still post – AmitS Sep 01 '14 at 06:13

3 Answers3

5

the following works for me:

  • open your Project Properties ("PROJECT" > "YourApp Properties...")

  • point the "Node.exe path" to nodemon.cmd (click on the button right of the input field, enter "%AppData%\npm\" in the adress bar, show all files, select "nodemon.cmd", save the properties form)

start debugger, or use "start without debugging" (Ctrl+F5)

indus
  • 66
  • 1
  • 3
  • This worked for me, although since I'm using nvm for windows I had to follow the symlink in my `c:\Program Files\node` directory to find nodemon.cmd. – keithl8041 Jun 15 '15 at 21:56
  • In VS2017 it actually starts the `nodemon` but then fails with the error: **(node:17996) [DEP0062] DeprecationWarning: `node --debug` and `node --debug-brk` are invalid. Please use `node --inspect` or `node --inspect-brk` instead.** I can't find where these deprecated params are set. – Serg Oct 02 '18 at 09:16
3

The accepted answer didn't work for me, as there was no nodemon.cmd file in my Nodemon installation. Perhaps things have changed.

This did work, however:

In the project properties, I simply set the Node.exe options to "C:\Program Files (x86)\nodejs\node_modules\nodemon\bin\nodemon.js" server.js

Note that my TypeScript file is server.ts, but I used the compiled filename server.js in the Node.exe options.

enter image description here

Josh1billion
  • 14,837
  • 8
  • 38
  • 48
1

Try to use last version of NTVS(Node Tools for Visual Studio).

Now when I run app in debug and change some code server restart and apply changes. It's amazing in new version!

Norbert Pisz
  • 3,392
  • 3
  • 27
  • 42
  • hmm, I downloaded the latest version of NTVS and it still didn't automatically restart the server after I edited my code. I am using VS Pro 2013 Update 2 – AmitS Sep 12 '14 at 00:14
  • EDIT : its working for me, I didn't realize before because VS doesnt show the server restarting in the terminal. Anyhow, the server restarts almost instantly while nodemon would take about 10 seconds to restart. This is amazing, thank you! – AmitS Sep 20 '14 at 23:20
  • 1
    With 1.0 Beta 3 it's not restarting automatically? – kayz1 Nov 04 '14 at 08:41
  • 1
    With 1.0 RC 2 (& VS 2013 Update 4) its not restarting either. Not sure how this can be a verified answer? – devman81 Mar 09 '15 at 11:25
  • Here also, VS 2013 Update 4, not restarting – SudoNhim Mar 30 '15 at 05:21
  • VS 2013 Update 4, NTVS 1.0 - seems to work only after I break in a TS file (I use TypeScript), and then only for that specific TS file... after I break once - every change to that TS file gets applied to the running node (or causes node to restart, not sure how it's implemented). Does anyone know how to make any change in any file always apply without needing to break inside that file first..? – obe Jul 11 '15 at 14:07