在一个MVC核心项目中,我使用以下命令将以前工作的项目从Angular 4升级到Angular 5
npm install @angular/animations@'^5.2.0' @angular/common@'^5.2.0' angular/compiler@'^5.2.0' @angular/compiler-cli@'^5.2.0' @angular/core@'^5.2.0' @angular/forms@'^5.2.0' @angular/http@'^5.2.0' @angular/platform-browser@'^5.2.0' @angular/platform-browser-dynamic@'^5.2.0' @angular/platform-server@'^5.2.0' angular/router@'^5.2.0' typescript@2.4.2 rxjs@'^5.5.2'
您可以在package.json中看到版本号已更改
{
"name": "Infobase.Angular",
"private": true,
"version": "0.0.0",
"scripts": {
"build": "webpack",
"test": "karma start ClientApp/test/karma.conf.js"
},
"devDependencies": {
"@angular/animations": "^5.2.0",
"@angular/cli": "^1.7.4",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/compiler-cli": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/platform-server": "^5.2.0",
"@angular/router": "^5.2.0",
"@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.5",
"@ngtools/webpack": "1.5.0",
"@types/chai": "4.0.1",
"@types/jasmine": "2.5.53",
"@types/webpack-env": "1.13.0",
"angular2-router-loader": "0.3.5",
"angular2-template-loader": "0.6.2",
"aspnet-prerendering": "^3.0.1",
"aspnet-webpack": "^2.0.1",
"awesome-typescript-loader": "3.2.1",
"bootstrap": "3.3.7",
"chai": "4.0.2",
"core-js": "^2.5.1",
"css": "2.2.1",
"css-loader": "0.28.4",
"es6-shim": "0.35.3",
"event-source-polyfill": "0.0.9",
"expose-loader": "0.7.3",
"extract-text-webpack-plugin": "2.1.2",
"file-loader": "0.11.2",
"html-loader": "0.4.5",
"isomorphic-fetch": "2.2.1",
"jasmine-core": "2.6.4",
"jquery": "3.2.1",
"json-loader": "0.5.4",
"karma": "1.7.0",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-cli": "1.0.1",
"karma-jasmine": "1.1.0",
"karma-webpack": "2.0.3",
"ng-drag-drop": "^4.0.0",
"preboot": "4.5.2",
"raw-loader": "0.5.1",
"reflect-metadata": "0.1.10",
"rxjs": "^5.5.2",
"style-loader": "0.18.2",
"systemjs": "^0.19.47",
"to-string-loader": "1.1.5",
"ts-loader": "^4.0.0",
"typescript": "^2.4.2",
"url-loader": "0.5.9",
"webpack": "2.5.1",
"webpack-hot-middleware": "2.18.2",
"webpack-merge": "4.1.0",
"zone.js": "0.8.12"
}
}
然后,我构建并启动了网站,在Startup.cs的Configure方法中出现错误
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
ConfigureDependencyInjection();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
{
HotModuleReplacement = true
});
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
if (_useIdServer)
{
app.UseAuthentication();
}
app.UseSession();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
routes.MapSpaFallbackRoute(
name: "spa-fallback",
defaults: new { controller = "Home", action = "Index" });
});
}
异常发生在“app.UseWebpackDevMiddleware”行上,并且为:
AggregateException: One or more errors occurred. (Version of
@angular/compiler-cli needs to be 2.3.1 or greater.
Current version is "5.2.0".
我很困惑,因为我认为5.2.0应该高于2.3.1。一位同事指出,5.2.0是用引号引起来的,按字母顺序“5.2.0”应该在2.3.1之前
有什么想法吗?
1条答案
按热度按时间u0njafvf1#
您确定执行
npm intall
时没有发生错误吗?请尝试npm update
,它可能会修正错误。