简体   繁体   English

从角度4升级到角度5后的Webpack错误

[英]Webpack error after upgrading from angular 4 to angular 5

In an MVC core project, I upgraded a previously working project from Angular 4 to Angular 5 using the command 在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'

You can see the version numbers have changed in the package.json 您可以在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"
  }
}

I then built and launched the website, getting an error in the Configure method of the Startup.cs 然后,我建立并启动了网站,在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" });
        });
    }

The exception occurs on the line "app.UseWebpackDevMiddleware" and is: 该异常发生在“ 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".

I'm confused as I would expect that 5.2.0 to be higher than 2.3.1. 我很困惑,因为我希望5.2.0会高于2.3.1。 A colleague pointed out that the 5.2.0 was in quotes and that alphabetically "5.2.0" would come before 2.3.1 一位同事指出5.2.0用引号引起来,按字母顺序,“ 5.2.0”应位于2.3.1之前。

Any ideas? 有任何想法吗?

Are you sure there were no errors during the npm intall ? 您确定在npm intall期间没有错误吗? Try npm update , it might fix it. 尝试npm update ,它可能会解决它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM