问题
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
回答1:
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)
回答2:
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.
回答3:
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!
来源:https://stackoverflow.com/questions/25210393/how-to-use-nodemon-in-ntvsnode-tools-for-visual-studio