NightCabbage
NightCabbage

Reputation: 489

Angular 2.0.0 rc0 in Visual Studio 2015 - npm not working

I am using the new Angular 2.0.0 rc0 release inside Visual Studio 2015 Update 2.

Previously (Angular 2 beta 17) I could create my "package.json" file, with the correct dependencies, then right-click it and select "restore packages", and it would create a "node_modules" folder, and install the correct files.

Now, I have a new "package.json" file, with the correct angular 2.0.0 rc0 dependencies inside, and when I do a "restore packages" on that, it does not create a "node_modules" folder, and instead just outputs a whole bunch of errors (mainly 404 and 304, that sort of thing).

I can do the "Angular 2 Quickstart" with my installed version of npm without a problem. I'm thinking it may be a problem with Visual Studio's internal version of npm? Maybe it's an old version or something?

If I do an "npm install" (via command line) on my project directory, it correctly creates the "node_modules" folder... but I want VS2015 to be able to do this!

Anyone have ideas?

Upvotes: 3

Views: 914

Answers (2)

Robert Swilley
Robert Swilley

Reputation: 502

Credit to David Pine's Post: https://ievangelistblog.wordpress.com/2016/01/13/building-an-angular2-spa-with-asp-net-5-mvc-6-web-api-2-and-typescript-1-7-5/

This worked for me (excerpt from post):

"While Node.js and its corresponding package manager, namely “npm” are part of the install for Visual Studio 2015 – it installs with 1.4.9 which is unfortunately an outdated version . Angular2 might play nicer with a later version of npm.

Let’s address this now, so that we do not run into issues once we start writing code. Install the latest version of Node.js here. Once installed navigate to the following directory:

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

Open the npm.cmd file in your favorite text editor (running as Administrator) and replace the contents of this file with the following:

@"C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" %*

Now Visual Studio 2015 will utilize the npm version that was installed from the aforementioned steps."

Upvotes: 2

James
James

Reputation: 2841

From VS, go to Tools --> Projects and Solutions --> External Web Tools.

Click the 'Add' button on the top right, and add the location of your nodejs install (something like C:\Program Files\nodejs), and move this to the top of the list.

This will cause VS to use your installed nodejs version, and fix this error.

Upvotes: 2

Related Questions