NPM, package.json - how to add a dependency named "@"

I am trying to install a new Angular 2 RC in my project. The module name in NPM has been changed from angular2 to @angular/core . But when I add it to my package.json , it tries to install the angular/core module instead and does not find it. When i type

 npm install @angular/core 

in the console, then Angular 2 is installed correctly. Do you know why package.json skipps "@" in the module name and how to fix it?

// Edit: I found out that this is not just a name, but "@" stands for scoped package . In any case, this should work using package.json (as described in the documentation ), but for some reason does not. I am using Visual Studio 2015 with the latest updates, and my project is an ASP.NET MVC 6 project (which is equipped with npm support).

+7
angular npm
source share
2 answers

You should use package.json from Angular2 Docs :

 { "dependencies": { "@angular/common": "2.0.0-rc.0", "@angular/compiler": "2.0.0-rc.0", "@angular/core": "2.0.0-rc.0", "@angular/http": "2.0.0-rc.0", "@angular/platform-browser": "2.0.0-rc.0", "@angular/platform-browser-dynamic": "2.0.0-rc.0", "@angular/router-deprecated": "2.0.0-rc.0", "@angular/upgrade": "2.0.0-rc.0", "systemjs": "0.19.27", "es6-shim": "^0.35.0", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.6", "zone.js": "^0.6.12", "angular2-in-memory-web-api": "0.0.5", "bootstrap": "^3.3.6" }, "devDependencies": { "concurrently": "^2.0.0", "lite-server": "^2.2.0", "typescript": "^1.8.10", "typings": "^0.8.1" } } 

Then check and run npm install in the root directory.

+4
source share

Thanks @Dov Benyomin Sohacheski, I did not know about this file. But, unfortunately, this did not solve my problem. The key was my use of Visual Studio 2015 and the possible outdated version of NPM that was shipped with it. I installed Node.js and set up Visual Studio to use this version instead of the built-in one, and it started working.

Here is a tutorial on how to get VS to use its own version of GIT instead of the built-in. The steps for NPMs are basically the same. One important difference is that you cannot simply uncheck the $(DevEnvDir)\Extensions\Microsoft\Web Tools\External because there are other tools, so you need to add the NPM location above it.

My final configuration: configuration

Remember to restart VisualStudio after this.

+2
source share

All Articles