gpt4 book ai didi

angular - 将 Angular 11 应用程序升级到 Angular 12 时遇到问题

转载 作者:行者123 更新时间:2023-12-05 05:59:33 33 4
gpt4 key购买 nike

当我们尝试将 Angular 11 应用程序(单 SPA 微前端)更新到 Angular 12 时,我们面临以下问题。

尝试运行此应用时控制台出现错误:

An unhandled exception occurred: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
  • configuration.output 有一个未知的属性“chunkLoadingGlobal”。这些属性是有效的:object { auxiliaryComment?,chunkCallbackName?,chunkFilename?,chunkLoadTimeout?,crossOriginLoading?,devtoolFallbackModuleFilenameTemplate?,devtoolLineToLine? hotUpdateChunkFilename?,hotUpdateFunction?,hotUpdateMainFilename?,jsonpFunction?,jsonpScriptType?,library?,libraryExport?,libraryTarget?,path?,pathinfo?,publicPath?,sourceMapFilename?,sourcePrefix?,strictModuleExceptionHandling?,umdNamedDefine?,webassemblyModuleFilename? }-> 影响编译输出的选项。 output 选项告诉 webpack 如何将编译后的文件写入磁盘。有关详细信息,请参阅“C:\Users\newUser\AppData\Local\Temp\ng-UOeNLu\angular-errors.log”。

Package.json:

    "name": "my-app",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "npm run serve",
"devstart": "ng serve --aot=false",
"build": "npm run build",
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/animations": "~12.0.5",
"@angular/cdk": "^12.0.5",
"@angular/common": "~12.0.5",
"@angular/compiler": "~12.0.5",
"@angular/core": "~12.0.5",
"@angular/forms": "~12.0.5",
"@angular/material": "^12.0.5",
"@angular/platform-browser": "~12.0.5",
"@angular/platform-browser-dynamic": "~12.0.5",
"@angular/router": "~12.0.5",
"@material-extended/mde": "^3.0.3",
"bootstrap-4-grid": "^3.4.0",
"highcharts": "^8.1.2",
"html2canvas": "^1.0.0-rc.7",
"htmldiff-js": "^1.0.5",
"http-server": "^0.12.3",
"jquery": "^3.5.1",
"jspdf": "^2.1.1",
"mat-table-exporter": "^9.0.0",
"ngx-mat-select-search": "^2.1.2",
"ng2-file-upload": "^1.4.0",
"ngx-matomo": "^0.1.4",
"ngx-summernote": "^0.8.0",
"ngx-order-pipe": "^2.0.4",
"rxjs": "~6.5.4",
"single-spa": ">=4.0.0",
"single-spa-angular": "5.0.1",
"tslib": "^2.0.0",
"summernote": "^0.8.18",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-builders/custom-webpack": "9.2.1-beta.0",
"@angular-devkit/build-angular": "~0.1102.13",
"@angular/cli": "~12.0.5",
"@angular/compiler-cli": "~12.0.5",
"@angular/language-service": "~12.0.5",
"@types/node": "^12.11.1",
"@types/jasmine": "~3.6.0",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.2.4"
}
}

Angular.json:

{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"my-app": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-builders/custom-webpack:browser",
"options": {
"outputPath": "dist/my-app",
"index": "src/index.html",
"main": "src/main.single-spa.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"./node_modules/bootstrap-4-grid/scss/grid.scss",
"src/styles.scss",
"node_modules/summernote/dist/summernote-lite.min.css"
],
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/summernote/dist/summernote-lite.min.js"
],
"customWebpackConfig": {
"path": "extra-webpack.config.js",
"libraryName": "my-app",
"libraryTarget": "umd"
}
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "none",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "20kb"
}
]
}
}
},
"serve": {
"builder": "@angular-builders/custom-webpack:dev-server",
"options": {
"browserTarget": "my-app:build"
},
"configurations": {
"production": {
"browserTarget": "my-app:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "my-app:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.scss"
],
"scripts": []
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json",
"e2e/tsconfig.json"
],
"exclude": [
"**/node_modules/**"
]
}
},
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "my-app:serve"
},
"configurations": {
"production": {
"devServerTarget": "my-app:serve:production"
}
}
}
}
}
},
"defaultProject": "my-app",
"cli": {
"analytics": false
}
}```

最佳答案

我遇到了同样的问题。更改某些依赖项的版本和 package.json 中的 devDependencies 为我解决了这个问题。

更改依赖项以具有以下内容:

  • "single-spa": "5.9.3"
  • "single-spa-angular": "5.0.2"

将开发依赖项更改为具有以下内容:

  • "@angular-builders/custom-webpack": "12.1.3"
  • "@angular-devkit/build-angular": "12.2.16"

关于angular - 将 Angular 11 应用程序升级到 Angular 12 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68097984/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com