2016-05-03 152 views
7

我想在我的項目中安裝新的Angular 2 RC。 NPM中的模塊名稱從angular2更改爲@angular/core。但是,當我將它添加到我的package.json時,它會嘗試安裝模塊angular/core,而不會找到它。當我輸入NPM,package.json - 如何在名稱中添加與「@」的依賴關係

npm install @angular/core 

在控制檯中,然後Angular 2被正確安裝。你知道爲什麼package.json模塊名稱中的skipps「@」以及如何解決它?

//編輯:我發現它不只是一個名字,而是「@」表示一個scoped package。無論如何,這應該使用package.json(如documentation中所述),但由於某些原因不會。 我使用Visual Studio 2015最新更新和我的項目是一個ASP.NET MVC 6項目(配有NPM支持)

+0

您應該使用https://angular.io/docs/ts/latest/guide/npm-packages.html –

回答

4

您應該使用package.jsonAngular2 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" 
    } 
} 

然後使確定並在根目錄下運行npm install

+0

中的'package.json'不適合我(visual studio 2015社區) – nadav

2

謝謝@Dov Benyomin Sohacheski,我不知道這個文件。 但不幸的是,它並沒有解決我的問題。關鍵是我使用了Visual Studio 2015以及隨附的可能過時的NPM版本。我安裝了Node.js並將Visual Studio配置爲使用此版本而不是內置版本,並開始工作。

Here是如何讓VS使用我們自己版本的GIT而不是內置教程的教程。 NPM的步驟基本相同。一個重要的區別是你不能只取消選中$(DevEnvDir)\Extensions\Microsoft\Web Tools\External,因爲還有其他工具,所以你需要在它上面添加NPM的位置。

我的最終配置: configuration

不要忘記之後重新啓動的VisualStudio。

相關問題