将Angular 6.1更新为Angular 8后键入ng serve时出现Webpack配置错误

时间:2020-01-14 16:38:26

标签: angular webpack config

我键入了命令ng update @angular/cli @angular/core,然后删除了node_modules文件,然后删除了npm install

输入ng serve

时出现错误
An unhandled exception occurred: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.output has an unknown property 'futureEmitAssets'. These properties are valid:
   object { auxiliaryComment?, chunkCallbackName?, chunkFilename?, chunkLoadTimeout?, crossOriginLoading?, devtoolFallbackModuleFilenameTemplate?, devtoolLineToLine?, devtoolModuleFilenameTemplate?, devtoolNamespace?, filename?, globalObject?, hashDigest?, hashDigestLength?, hashFunction?, hashSalt?, hotUpdateChunkFilename?, hotUpdateFunction?, hotUpdateMainFilename?, jsonpFunction?, jsonpScriptType?, library?, libraryExport?, libraryTarget?, path?, pathinfo?, publicPath?, sourceMapFilename?, sourcePrefix?, strictModuleExceptionHandling?, umdNamedDefine?, webassemblyModuleFilename? }
   -> Options affecting the output of the compilation. `output` options tell webpack how to write the compiled files to disk.
See "/tmp/ng-bHnTFp/angular-errors.log" for further details.

我的package.json

{
  "name": "...",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@amcharts/amcharts4": "4.4.2",
    "@amcharts/amcharts4-geodata": "^4.0.21",
    "@angular/animations": "^8.2.14",
    "@angular/cdk": "^6.4.7",
    "@angular/common": "^8.2.14",
    "@angular/compiler": "^8.2.14",
    "@angular/core": "^8.2.14",
    "@angular/flex-layout": "^6.0.0-beta.18",
    "@angular/forms": "^8.2.14",
    "@angular/material": "^6.4.7",
    "@angular/platform-browser": "^8.2.14",
    "@angular/platform-browser-dynamic": "^8.2.14",
    "@angular/router": "^8.2.14",
    "@types/paho-mqtt": "^1.0.4",
    "@types/zen-observable": "^0.5.4",
    "angular5-social-login": "^1.0.9",
    "aws-amplify": "^1.1.19",
    "aws-sdk": "^2.401.0",
    "core-js": "^2.6.4",
    "d3": "^5.9.1",
    "expo": "^31.0.6",
    "hammerjs": "^2.0.8",
    "mat-table-exporter": "^1.2.5",
    "moment": "^2.24.0",
    "ngx-facebook": "^2.4.0",
    "ngx-tour-core": "^4.0.1",
    "ngx-tour-md-menu": "^4.0.1",
    "rxjs": "^6.5.4",
    "rxjs-compat": "^6.4.0",
    "tslib": "^1.10.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.803.22",
    "@angular/cli": "^8.3.22",
    "@angular/compiler-cli": "^8.2.14",
    "@angular/language-service": "^8.2.14",
    "@types/jasmine": "^2.8.16",
    "@types/jasminewd2": "^2.0.6",
    "@types/node": "^10.12.26",
    "codelyzer": "^5.0.1",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^2.0.5",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.4.3",
    "karma-jasmine": "^1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "node-sass": "^4.13.0",
    "protractor": "^5.4.2",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "~3.5.3",
    "webpack": "4.28.4"
  }
}

1 个答案:

答案 0 :(得分:0)

这个错误主要是因为旧的依赖关系,如果根本没有升级,那么可以通过删除 node_modules 文件夹和 package-lock.json 文件手动删除它

之后你可以清理缓存(如果有必要的话)然后

npm 缓存清理 --force npm 安装

在升级到 Angular 和使用官方指南时这对我有用