Show / Hide Table of Contents

Node.js

Node.js Tools for Visual Studio projects are based on the solutions and projects model in Visual Studio. A Node.js project has a .njsproj extension and contains all the source code files, images, and configuration files like package.json.

Creating a Node.js Project

Visual Studio makes it easy to start a new Node.js project from scratch or based existing code. This is done through a number of pre-defined project templates, which are available both for TypeScript and JavaScript developers.

You can create a new project from the Start Page in Visual Studio, or by selecting File -> New Project in the menu. The project templates are listed in the Node.js subsection under the JavaScript and TypeScript language sections.

New Project Dialog

Project templates

Blank Node.js Console Application

This template is a very simple application that is a good starting point for any non-web Node.js project. With the default settings, your project will run and debug with the Node.js interpreter.

Blank Node.js Web Application

This template contains the most simple example of a Node.js based web server, and will run and debug in the web browser. This is a good starting point for understanding the very basics of Node.js based web applications.

Basic Node.js Express 4 Application

This template is based on the Node.js Express framework which is commonly used for creating Node.js based web apps, and will run and debug in the web browser. This template is recommended for building anything other than the most basic web apps.

Create Project from Existing files

If you already have existing Node.js code (e.g. generated by another tool) you can easily import this into a Visual Studio project. To get started, open up the new Project Dialog, and select the From Existing Node.js code template.

Tip

Make sure the location you select from the new project in the New Project Dialog, is on the same drive as the source code you want to add to project.

After selecting the template a wizard will open, which guides you through the selection of the file, and setting some default options, such as the startup file. When finished, Visual Studio will generate a project and solution file based on code you imported.

  • Improve this Doc
Back to top Generated by DocFX