我想使用ASP.NET MVC5和Angular2来创建一个应用程序。为此,我使用Visual Studio中名为"Angular2 Mvc5 sample application"的现成模板。随模板一起提供的package.json告诉它正在使用rc-1以及Angular 2和Typescript的相关依赖项。由于最新版本的Angular 2现在是2.4.0,我想在我的项目中使用最新版本的angular2。我怎样才能做到这一点?我尝试更新package.json文件并将版本更改为最新版本
{
"name": "aspnet",
"version": "0.0.0",
"scripts": {
"postinstall": "typings install",
"typings": "typings"
},
"license": "ISC",
"devDependencies": {
"typings": "0.8.1"
},
"dependencies": {
"@angular/common": "2.0.0-rc.1",
"@angular/compiler": "2.0.0-rc.1",
"@angular/core": "2.0.0-rc.1",
"@angular/http": "2.0.0-rc.1",
"@angular/platform-browser": "2.0.0-rc.1",
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
"@angular/router": "2.0.0-rc.1",
"@angular/router-deprecated": "2.0.0-rc.1",
"@angular/upgrade": "2.0.0-rc.1",
"systemjs": "0.19.27",
"core-js": "^2.4.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12",
"angular2-in-memory-web-api": "0.0.9"
}
}
我从angular cli项目中获取了一个引用来更新包,并在更新我的package.json之后看起来像
{
"name": "aspnet",
"version": "0.0.0",
"scripts": {
"postinstall": "typings install",
"typings": "typings"
},
"license": "ISC",
"devDependencies": {
"typings": "~2.0.0"
},
"dependencies": {
"@angular/common": "^2.4.0",
"@angular/compiler": "^2.4.0",
"@angular/core": "^2.4.0",
"@angular/forms": "^2.4.0",
"@angular/http": "^2.4.0",
"@angular/platform-browser": "^2.4.0",
"@angular/platform-browser-dynamic": "^2.4.0",
"@angular/router": "^3.4.0",
"systemjs": "0.19.27",
"reflect-metadata": "^0.1.3",
"core-js": "^2.4.1",
"rxjs": "^5.1.0",
"zone.js": "^0.7.6",
"angular2-in-memory-web-api": "0.0.9"
}
}
更新package.json>我恢复了包,但是在构建项目后我遇到了很多错误
答案 0 :(得分:1)
要将Angular升级到最新版本,请从package.json到您的package.json
选择并更新所需的软件包。并修复了更新nodejs
和npm
版本所需的错误。一旦安装了更新的nodejs和npm,您还必须在Visual Studio中添加nodejs
路径以使用最新版本的nodejs和npm。要在VS中添加路径,请转到工具>选项>项目和解决方案>外部Web工具。为此,您可以按照guide。