Developing the Node.js Program on Visual Studio 2012

Source: Internet
Author: User
Tags require install node

Recently ready to do something with node.js, so look for the ability to have Visual Studio plug-ins to facilitate development. As a result, a node.js Tools for Visual Studio (Ntvs) from Microsoft, which now publishes only 1.0 Alpha versions, are already very handy to use. Also, its development team is the same as Python Tools for Visual Studio (PTVs), and PTVs is the one that needs to be installed to create your own Python project in Visual Studio 2013, so you can use Ntvs with ease.

"First, Ntvs Introduction and Installation"

From its official website (, Ntvs is a free, open source plug-in that makes Visual Studio a Node.js integrated development environment, NTVS supports editing, Intellisense, Profiling, NPM Package Manager, local and remote debugging (Windows, MacOS, and Linux), while supporting Windows Azure Web sites and cloud services.

In short, there are all the. If you want to install Ntvs, you need the VS 2013 or Update4 Professional (or test Professional), Premium, or Ultimate version, At the same time need to install Node.js 0.10.20 or above version, with these preparations, you can go to the official website download installation package to install, it should be noted that VS 2013 and 2012 of the installation packages are independent.

After the installation is complete, the following project types are added to Visual Studio's JavaScript type:

"II, Ntvs project creation and use"

For Node.js, project types do not have as many different types as. NET projects, and there are differences in the development environment between each. For the blank Node.js console application and Web application two projects above, the code for the former template only provides the code to output Hello World at the console; The latter creates an HTTP server with node.js and outputs Hello world for each request, which implements a simple Web application. and express application is using the Express Framework on Node.js +jade template engine +stylus implemented a small Web application. The rest of the first project is created from an existing Node.js project, and the last two are similar to others, except that the scripts and configuration files have been configured to deploy directly to Windows Azure.

Project creation is not much different from Visual Studio's C # and so on, IntelliSense is also very powerful, typing require will prompt all the name of the module, while selecting each module will prompt the role and description of the module (pictured below), and type carriage return can be directly padded with single quotes, and so on, are very aspects. For each module, all of its methods and member variables are automatically displayed, except that they do not display descriptive information like require.

"Three, Ntvs project debugging"

Ntvs project debugging in the same way as C #, is F5 run and debug and Ctrl+f5 run without debugging, and it automatically runs the code of the installed node program to execute the current project. For Web application projects and the use of HTTP modules, the browser is also automatically opened to access the specified port (which can be closed in the project properties). It should be noted that for the Node.js project, there is and only one startup file (equivalent to the program's main () function), the program from the beginning of this file, by default, the first created after the project creation of the JS file as a startup file, the startup file in bold. If you need to set other files as startup files, right-click the Select settings (pictured below).

As with any other project during debugging, you can set breakpoints, single-step, and monitor what is available, and if you throw an exception in your program code, you will be prompted during debugging (pictured below).

By default, all exceptions are prompted, and of course you can choose which exceptions you want to not prompt. You can select "Open exception Settings" after prompting for an exception, or select "Debug" menu, select "Exceptions", as shown in the following figure:

"Four, Ntvs Project package Management"

Ntvs also provides a very convenient way to package management, adding additional packages as easily as adding references in a C # project. Of course, you can also use NPM to install the appropriate package, and then use it in your project, although debugging is not a problem, but there is no IntelliSense hint. So, if you need other packages in your project, you can right-click NPM, select "Manage npm Modules ..." (as shown below), enter the name of the package in the package name to the right of the NPM Package Manager, and then click Local Install below (Install for current project). When finished, the installed package appears on the left side, and the corresponding package name appears in the project, and the require of the method members are also available when using the package.

After the package is installed, the appropriate package name appears under NPM in Solution Manager, similar to the C # Project Add Reference. Also, as with the NPM ls command, you can view the dependencies of the package (pictured below).

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.