Configuring Visual Studio 2015 to use latest NPM
Many recent web technology packages (like Angular) are not available on nuget and have to be retrieved via Node's NPM. Visual Studio 2015 Update 3 uses a deprecated version of NPM, so here's a few easy steps to get the latest version up and running.
2: Configure Visual Studio to use NodeJS
Open the extras/options/projects and solutions/external web tools window
Add a location by clicking on the leftmost button in the top right corner. This will result in a new line. You will want to make this contain C:\Program Files (x86)\nodejs\ or wherever you installed NodeJS in step 1. Move this item to the top of the list so that VS primarily uses this location for NPM rather than its own installation.
3: Check
Create a new web solution (whatever floats your boat) and create a file named package.json at root level. The following text describes requirements for Angular development and can be used as a sample.
{
"dependencies": {
"@angular/common": "4.0.1",
"@angular/compiler": "4.0.1",
"@angular/core": "4.0.1",
"@angular/forms": "4.0.1",
"@angular/http": "4.0.1",
"@angular/platform-browser": "4.0.1",
"@angular/platform-browser-dynamic": "4.0.1",
"@angular/router": "4.0.1",
"core-js": "2.4.1",
"reflect-metadata": "0.1.10",
"rxjs": "5.3.0",
"systemjs": "0.20.11",
"zone.js": "0.8.5"
},
}
Right-click that file and pick "restore packages".
This should result in a node_modules folder at project root level. This folder is NOT part of your project, so you'll have to use the Show All Files toggle to reveal it.
4: [Optional] Configure Node JS to get past your Proxy.
This applies when restoring npm packages does not work.
Edit program files (x86)\nodejs\node_
proxy=
https-proxy=http://myproxy.mydomain.mytld:myport
Kommentare
Kommentar veröffentlichen