Developing a node. js program on Visual Studio 2013

Source: Internet
Author: User

"Off-topic"

Recently ready to do something with node. js, so look for a plugin on Visual Studio for easy development. It turned out to be one of the node. js Tools for Visual Studio (Ntvs) from Microsoft, although it is now easy to use because it only publishes the 1.0 Alpha version. Also, its development team is the same as Python Tools for Visual Studio (PTVS), and PTVS is the one you need to install in Visual Studio 2013 to create your own Python project. So can be assured of the use of Ntvs.

"Series Index"

    1. Developing the node. JS program on Visual Studio--ntvs introduction and use
    2. Developing the node. JS program on Visual Studio (2)--ntvs remote debugging and publishing to Azure

"Article index"

    1. Ntvs Introduction and Installation
    2. Ntvs Project creation and use
    3. Commissioning of the Ntvs project
    4. Package Management for NTVS projects

"I. Introduction and installation of Ntvs"

From its official website (http://nodejstools.codeplex.com), 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 of them. If you want to install Ntvs, you need the Professional (or test Professional), Premium, or Ultimate versions of VS 2013 or Update4 There is also a need to install the 0.10.20 or more version of node. JS, with these preparations, you can go to the official website to download the installation package to install, it should be noted that the VS 2013 and 2012 of the installation package is separate.

When the installation is complete, the following project types are added to the JavaScript types in Visual Studio:

"Second, Ntvs project creation and use"

For node. js, the project types are not as many different types as. NET projects, and there are differences in the development environment between each. For the above blank node. JS Console Application and Web application two projects, nothing but the former template code provides only the code in the console output Hello World While the latter creates an HTTP server with node. js and outputs Hello world for each request, a simple Web application is implemented. Express application, however, uses the Express Framework +jade template Engine on node. js to implement a small Web application +stylus. The rest of the first project was created from an existing node. JS project, and the latter two are similar to others, except that the scripts and configuration files that have been configured can be deployed directly into Windows Azure.

Project creation is not very different from Visual Studio C # and other projects, IntelliSense is also very powerful, when typing require will prompt all the module name, while selecting each module will prompt the role of the module and description (such as), Then type enter can be directly filled with single quotation marks and so on, are very convenient. For each module, all of its methods and member variables can be displayed automatically, except that it does not display the description information like require.

"Three, the commissioning of Ntvs project"

The Ntvs project is debugged in the same way as C #, where F5 runs and debugs and Ctrl+f5 only runs without debugging, which automatically runs the installed node program's code to execute the current project. For WEB application projects and using an HTTP module, the browser is also automatically opened to access the specified port (which can be turned off in the project properties). It should be explained that for the node. JS project, there is only one startup file (that is, the file executed with Node.exe, which is equivalent to the main () function of the program), and the program executes from the beginning of the file, by default the first JS file created after the project is created as the startup file. The startup file is in bold notation. If you need to set other files as startup files, right-click to select settings (for example).

During debugging, as with any other project, you can set breakpoints, step into, and monitor what is available, and if you throw an exception in your program code, you will be prompted (for example) during debugging.

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

"Iv. package management for NTVS projects"

Ntvs also provides a very convenient way to manage packages as easily as adding additional packages as you add references to a C # project. Of course, you can also use NPM to install the appropriate package, and then use it in the project, although debugging run no problem, but there is no IntelliSense hint. So, if you need additional packages in your project, you can right-click NPM, select "Manage npm Modules ..." (for example), enter the package name in the package name on the right side of the NPM Package Manager, and click on the local installation below (installed for the current project), which will be done on the left The installed packages appear, and the corresponding package names appear in the project require, as well as tips for method members when using the package.

After the package is installed, the corresponding package name appears under NPM in Solution Manager, similar to adding a reference to a C # project. Also, as with the NPM ls command, you can view the dependencies of the package (for example).

"RELATED LINKS"

    1. Introducing node. js Tools for Visual studio:http://www.hanselman.com/blog/introducingnodejstoolsforvisualstudio.aspx
    2. [Visual Studio] Ntvs-node.js Tools for Visual Studio bootcamp:http://www.dotblogs.com.tw/blackie1019/archive/2013/12/27/136557.aspx
    3. Microsoft Joins forces with Redgate and Clickberry to offer node. js Tools for Visual studio:http://www.infoq.com/news/2013 /12/ntvs

Reprinted from: http://www.cnblogs.com/mayswind/p/3547413.html

Developing a node. js program on Visual Studio 2013

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: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.