This article describes the step-by-step solution to set up Angular 2 with your Visual Studio 2015 IDE. This is for those who love Visual Studio as IDE.
Prerequisites
- Node JS
Node.js is required to setup this project. To install node.js, use this link here. Make sure that node version is 4.6.x or greater. To check the node version on your system, open command prompt and type the below command.
node - v
- NPM (Node Package Manager)
NPM is also required to setup this solution. Make sure NPM version must be 3.x.x or greater. To check the NPM version on your system, open command prompt and type the below command,
npm - v
- Visual Studio 2015 Update 3
Visual Studio with update 3 is required for this setup as earlier versions of VS do not follow the best practices for developing applications with TypeScript.
To check Visual Studio version installed on your system, go to Help Menu -> About Microsoft Visual Studio
If you do not have VS 2015 with update 3, click here to install.
- Typescript
TypeScript for Visual Studio is also required to setup this solution. Make sure TypeScript version must be 2.2 or greater. To check the TypeScript version on your system, Click on Help menu in Visual Studio and select About Microsoft Visual Studio,
To install TypeScript with Visual Studio 2015, click here
- Configure External Web Tools in Visual Studio
It is required to configure Visual Studio to use the global external web tools instead of only those tools which come with visual studio.
To configure it, Please follow the below steps,
- Go to Tools menu and click on Options.
- In the left tree, Select Project and Solutions and then External Web Tools
- In the right location window, Move the $(PATH) entry above the $(DevEnvDir)\....\External

- Click ok to close the window and restart visual studio.
Now the visual studio is ready for step-by-step setup.
Setup Angular 2 files with Visual Studio
Step 1. Create Empty ASP.NET Web Application project
- Run Visual Studio as Administrator
- Click on File -> New Project
- Select "Web" under "Visual C#". From the right pane select "ASP.NET Web Application"
- Name the project "Angular2StudentDemo"
- On the next screen, select "Empty" template and click "OK"

Step 2
Download the Angular QuickStart files from Github using below link. Download and extract the folder.
Step 3
Copy the required files (mentioned below and also shown in below screenshot) from QuickStart Files folder and paste to your just created web application project.
- src folder and it’s all contents
- bs-config.json file
- package.json file
- tslint.json file

Copy these above files and paste into your web application root directory. Now click on show all files in the solution explorer and right click on all those folder and files which you just pasted to your web app project.

While including above files in your project, if you get a window like below, then click “No”.

Step 4. Restore the packages
In the "Solution Explorer" right click on "package.json" file and select "Restore Packages" from the context menu.

After the restoration is complete, you will see a message "Installing Packages Complete" like below,

To see all the installed node modules, click on "Show All Files" in Solution Explorer.
Note
DO NOT include "node_modules" folder in the project.
Step 5. Build and run the project with Visual Studio F5
Firs, make your index.html file as your start up page. Right click on src/app/index.html file in the Solution Explorer and select option “Set As Start Page”.
To run your Angular project using Visual Studio via F5, you need to do the following changes –




Rohit KumarPosted Nov 30, 2018, 7:36 AM
Hi I am unable to restore packages using restore packages and getting bellow exception npm ERR! Error: Method Not Allowed npm ERR! at errorResponse (C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\npm\node_modules\npm\lib\cache.js:753:14) npm ERR! at C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\npm\node_modules\npm\lib\cache.js:773:12 npm ERR! at saved (C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\npm\node_modules\npm-registry-client\lib\get.js:148:7) npm ERR! at C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\npm\node_modules\graceful-fs\polyfills.js:133:7 npm ERR! at Object.oncomplete (fs.js:107:15) npm ERR! If you need help, you may report this *entire* log, npm ERR! including the npm and node versions, at: npm ERR! <http://github.com/npm/npm/issues> npm ERR! System Windows_NT 6.2.9200 npm ERR! command "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Extensions\\Microsoft\\Web Tools\\External\\\\node\\node" "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Extensions\\Microsoft\\Web Tools\\External\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" npm ERR! cwd C:\Angular2Demo\Angular2Demo npm ERR! node -v v0.10.31 npm ERR! npm -v 1.4.9 npm ERR! code E405
Rohit KumarPosted Nov 30, 2018, 7:36 AM
Hi I am unable to restore packages using restore packages and getting exception
Rohit KumarPosted Nov 30, 2018, 7:35 AM
Hi I am unable to restore packages using package.json
Ajay GuptaPosted Sep 18, 2018, 3:48 AM
How to use anguler 2 with asp.net mvc ?
Himanshu GuptaPosted Aug 27, 2018, 2:49 AM
I am getting error in console after running the application."NetworkError: 404 Not Found - http://localhost:50329/main.js".Where is the location of this script path?
chethan bvPosted Jul 17, 2018, 7:24 AM
Hi when i install angular-4 fusion charts module i am getting error like this please help me how to solve this https://i.stack.imgur.com/XZgco.png
jubula samalPosted Jul 16, 2018, 2:01 PM
Superb and it is very useful
Jayant SatkarPosted Dec 31, 2017, 3:28 AM
Hi Rahul, On Package restore I'm getting error code (Exit code ) 1 or 4048.
sourabh sukhijaPosted Oct 8, 2017, 12:43 PM
Hi,I am getting following error, can you plz help me? http://prntscr.com/gutilu
Micah (JustAnotherHuman)Posted Jul 22, 2017, 5:06 PM
You SHOULD NOT be using systemjs. Systemjs is an old tech module loader that, when used in production, makes an http call for each and every file in the project including node_modules. Use webpack, rollup, or angulars cli builder. Also #ItsJustAngular