NPM Nodejs Angular2 and Visual Studio 2015 headaches

I decided it was about time I get to grips with Typescript and Angular2, Visual Studio 2015 has lots of support for the front end frameworks but sadly my experience so far has been that of frustration before even writing a line of code.

Looking at the Angular2 quick start guide there is certainly plenty of help to get you going but in a non Windows / Visual Studio environment.

I had naively assumed that since Visual Studio 2015 has so much support for things like Typescript, Angular and Nodejs OOTB that I could just get up and running straight away. But I hit a roadblock on step 1 trying to use npm to get the Angular2 packages into the solution.

After adding the package.json file to my solution Visual Studio runs npm install automatically, which is a nice feature until it spews out cryptic error messages such as:

NPM ERR 404 'angular' is not in the npm registry

The problem is that even after update 2 on Visual Studio 2015 it was still using npm 2.14.4 and node 4.1.1. If you want to use Angualr2 you need at least node v5.x.x and npm 3.x.x.

Visual Studio has its own install of nodejs hidden away usually under

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External

and it will always use this version, so you need to manually force Visual Studio to use the latest version.

Visual Studio updates still appear to be a bit behind when it comes to the version of nodejs it uses or this may simply be for ensured compatibility. You can see the version by typing the follwing into the Package Manager Console:

npm -v and node -v

To fix this Download the relevant package from Note the LTS release recommended for most users is not suitable.

Once nodejs is installed fire up your Visual Studio solution and go to:

Debug -> Options -> Projects and Solutions -> External Web Tools.

In here you can add the location for the new version of nodejs. This will probably be C:\Program Files\nodejs depending on your system. If you add this above the existing entries Visual Studio should then use the new version.

You may need to restart Visual Studio and clear your npm cache by running 

npm cache clean

After following those steps npm seems to run without error for me. One interesting thing is that despite it using the new version if you type npm -v into the Package Manager it will still show the internal version.