Running NodeJs from Visual Studio
Creating a NodeJs application becomes far more enjoyable when you can easily use the features of Visual Studio.
It's a pseudo hack around to do it, but you can set it up by creating a new ASP.Net Web Application project in Visual Studio.
Open up the project properties.
Select the Web tab.
Under Start Action select 'Start external program'
Application - C:\Windows\System32\cmd.exe
Command line arguments - /k node app.js & pause & exit
Working Directory - [Your current project directory]
If you use another file name for your NodeJs app, you'll have to rename app.js in the command line argument.
This doesn't work as well for working on a team project since the working directory is dependent on your set up. But this works really well for quickly running NodeJs inside Visual Studio.
Written by Garrett Hoofman
Related protips
4 Responses
Can you debug node with VS?
Nope, no debugging, only advantages are staying in Visual Studio, and using the Javascript intellisense.
This is an awesome tip. Can we create a Visual Studio template or something that automatically fills out these properties for every new project we create of type node.js (probably with express)?
I tried creating Web Site instead of Web Application, so we can delete all the folders in solution and fire Express <appname> on the root to have only needed files and no extra solution files (not in the app folder at least) and bin and Obj folders.
I am not sure but doing Web Site will also not compile the project into DLL
Is there anyway to save the working directory using $(SolutionDir)?