Many Gatsby plugins and themes require building native Node.js modules, e.g. If your windows-build-tools installation stalls after Visual Studio Build Tools.
Active4 years ago
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 clearhttps://nodejstools.codeplex.com/workitem/545
AmitSAmitS
3 Answers
the following works for me:
- open your Project Properties ('PROJECT' > 'YourApp Properties...')
- point the 'Node.exe path' to nodemon.cmd (click on the button rightof the input field, enter '%AppData%npm' in the adress bar, showall files, select 'nodemon.cmd', save the properties form)
start debugger, or use 'start without debugging' (Ctrl+F5)
indusindus
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)nodejsnode_modulesnodemonbinnodemon.js' server.js
Note that my TypeScript file is server.ts, but I used the compiled filename server.js in the Node.exe options.
Josh1billionJosh1billion13.5k88 gold badges3030 silver badges4545 bronze badges
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 PiszNorbert Pisz2,62333 gold badges2222 silver badges3939 bronze badges
Not the answer you're looking for? Browse other questions tagged node.jsvisual-studio-2013nodemon or ask your own question.
-->In this 5-10 minute introduction to the Visual Studio integrated development environment (IDE), you'll create a simple Node.js web application.
Prerequisites
- You must have Visual Studio installed and the Node.js development workload.If you haven't already installed Visual Studio 2019, go to the Visual Studio downloads page to install it for free.If you haven't already installed Visual Studio 2017, go to the Visual Studio downloads page to install it for free.If you need to install the workload but already have Visual Studio, go to Tools > Get Tools and Features..., which opens the Visual Studio Installer. Choose the Node.js development workload, then choose Modify.
- You must have the Node.js runtime installed.If you don't have it installed, install the LTS version from the Node.js website. In general, Visual Studio automatically detects the installed Node.js runtime. If it does not detect an installed runtime, you can configure your project to reference the installed runtime in the properties page (after you create a project, right-click the project node and choose Properties).
Create a project
First, you'll create an Node.js web application project.
- If you don't have the Node.js runtime already installed, install the LTS version from the Node.js website.In general, Visual Studio automatically detects the installed Node.js runtime. If it does not detect an installed runtime, you can configure your project to reference the installed runtime in the properties page (after you create a project, right-click the project node and choose Properties).
- Open Visual Studio.
- Create a new project.Press Esc to close the start window. Type Ctrl + Q to open the search box, type Node.js, then choose Create new Blank Node.js Web application project (JavaScript). In the dialog box that appears, choose Create.From the top menu bar, choose File > New > Project. In the left pane of the New Project dialog box, expand JavaScript, then choose Node.js. In the middle pane, choose Blank Node.js Web application, then choose OK.If you don't see the Blank Node.js Web application project template, you must add the Node.js development workload. For detailed instructions, see the Prerequisites.Visual Studio creates and the new solution and opens the project. server.js opens in the editor in the left pane.
Explore the IDE
- Take a look at Solution Explorer in the right pane.
- Highlighted in bold is your project, using the name you gave in the New Project dialog box. On disk, this project is represented by a .njsproj file in your project folder.
- At the top level is a solution, which by default has the same name as your project. A solution, represented by a .sln file on disk, is a container for one or more related projects.
- The npm node shows any installed npm packages. You can right-click the npm node to search for and install npm packages using a dialog box.
- If you want to install npm packages or Node.js commands from a command prompt, right-click the project node and choose Open Command Prompt Here.
- In the server.js file in the editor (left pane), choose
http.createServer
and then press F12 or choose Go To Definition from the context (right-click) menu. This command takes you to the definition of thecreateServer
function in index.d.ts. - Got back to server.js, then put your cursor at the end of the string in this line of code,
res.end('Hello Worldn');
, and modify it so that it looks like this:res.end('Hello Worldn' + res.connection.
Where you typeconnection.
, IntelliSense provides options to auto-complete the code entry. - Choose localPort, and then type
);
to complete the statement so that it looks like this:res.end('Hello Worldn' + res.connection.localPort);
Run the application
- Press Ctrl+F5 (or Debug > Start Without Debugging) to run the application. The app opens in a browser.
- In the browser window, you will see 'Hello World' plus the local port number.
- Close the web browser.
Congratulations on completing this Quickstart in which you got started with the Visual Studio IDE and Node.js. If you'd like to delve deeper into its capabilities, continue with a tutorial in the Tutorials section of the table of contents.