Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM, package.json - how to add dependency with "@" in name

I am trying to install new Angular 2 RC in my project. Module name in NPM was changed from angular2 to @angular/core. But when I add it to my package.json, it tries to install module angular/core instead and doesn't find it. When I type

npm install @angular/core

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

//Edit: I found out that it's not just a name, but "@" indicates a scoped package. Anyway, this should work using package.json (as described in documentation), but for some reason doesn't. I am using Visual Studio 2015 with latest updates and my project is an ASP.NET MVC 6 project (which comes equipped with npm support)

like image 597
emsi Avatar asked May 03 '16 15:05

emsi


2 Answers

You should use the 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 make sure and run npm install in the root directory.

like image 116
Dov Benyomin Sohacheski Avatar answered Oct 19 '22 00:10

Dov Benyomin Sohacheski


Thanks @Dov Benyomin Sohacheski, I wasn't aware of this file. But unfortunately it didn't resolve my problem. The key was my usage of Visual Studio 2015 and possible outdated version of NPM that shipped with it. I installed Node.js and configured Visual Studio to use this version instead of built-in one and it started working.

Here is a tutorial of how to make VS use our own version of GIT instead of built-in one. Steps for NPM are basically the same. One important difference is you cannot just uncheck $(DevEnvDir)\Extensions\Microsoft\Web Tools\External, because there are also other tools, so you need to add location of NPM above it.

My final configuration: configuration

Don't forget to restart VisualStudio after that.

like image 31
emsi Avatar answered Oct 19 '22 00:10

emsi