2

我有一个基于 Angular 10.0.11的项目。

我用 将项目更新到10.2,但是在尝试构建时npm update,这导致了多个-errorsUnable to fully load [...] for source-map flattening: Circular source file mapping dependency

我解决了它:

rm -rf node_modules package-lock.json
npm install

但我仍然无法构建。在该过程结束时,我收到此错误:

[...]
Generating ES5 bundles for differential loading...
ES5 bundle generation complete.
Generating localized bundles...
Localized bundle generation failed: Cannot read property 'value' of undefined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ed-app@0.0.0 build-prod-da: `ng build --prod --configuration=production-da`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the ed-app@0.0.0 build-prod-da script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/jde/.npm/_logs/2021-02-10T12_06_55_122Z-debug.log

我无法弄清楚这里出了什么问题。根据“Angular 更新指南”,从 10.0 更新到 10.2 应该是小菜一碟。

这是日志文件的内容:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/local/bin/npm', 'run', 'build-prod-da' ]
2 info using npm@6.14.11
3 info using node@v14.15.4
4 verbose run-script [ 'prebuild-prod-da', 'build-prod-da', 'postbuild-prod-da' ]
5 info lifecycle ed-app@0.0.0~prebuild-prod-da: ed-app@0.0.0
6 verbose lifecycle ed-app@0.0.0~prebuild-prod-da: unsafe-perm in lifecycle true
7 verbose lifecycle ed-app@0.0.0~prebuild-prod-da: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/jde/edApp2Angular10Prerender2/node_modules/.bin:/usr/share/Modules/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/opt/gradle/gradle-6.8.1/bin:/var/lib/snapd/snap/bin:/home/jde/flutter_projects/flutter/bin:/home/jde/.local/bin:/home/jde/bin:/home/jde/flutter_projects/flutter/bin:/opt/gradle/gradle-6.8.1/bin:/home/jde/flutter_projects/flutter/bin:/home/jde/.local/bin:/home/jde/bin:/home/jde/flutter_projects/flutter/bin:/opt/gradle/gradle-6.8.1/bin
8 verbose lifecycle ed-app@0.0.0~prebuild-prod-da: CWD: /home/jde/edApp2Angular10Prerender2
9 silly lifecycle ed-app@0.0.0~prebuild-prod-da: Args: [ '-c', 'npm run before-build' ]
10 silly lifecycle ed-app@0.0.0~prebuild-prod-da: Returned: code: 0  signal: null
11 info lifecycle ed-app@0.0.0~build-prod-da: ed-app@0.0.0
12 verbose lifecycle ed-app@0.0.0~build-prod-da: unsafe-perm in lifecycle true
13 verbose lifecycle ed-app@0.0.0~build-prod-da: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/jde/edApp2Angular10Prerender2/node_modules/.bin:/usr/share/Modules/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/opt/gradle/gradle-6.8.1/bin:/var/lib/snapd/snap/bin:/home/jde/flutter_projects/flutter/bin:/home/jde/.local/bin:/home/jde/bin:/home/jde/flutter_projects/flutter/bin:/opt/gradle/gradle-6.8.1/bin:/home/jde/flutter_projects/flutter/bin:/home/jde/.local/bin:/home/jde/bin:/home/jde/flutter_projects/flutter/bin:/opt/gradle/gradle-6.8.1/bin
14 verbose lifecycle ed-app@0.0.0~build-prod-da: CWD: /home/jde/edApp2Angular10Prerender2
15 silly lifecycle ed-app@0.0.0~build-prod-da: Args: [ '-c', 'ng build --prod --configuration=production-da' ]
16 silly lifecycle ed-app@0.0.0~build-prod-da: Returned: code: 1  signal: null
17 info lifecycle ed-app@0.0.0~build-prod-da: Failed to exec build-prod-da script
18 verbose stack Error: ed-app@0.0.0 build-prod-da: `ng build --prod --configuration=production-da`
18 verbose stack Exit status 1
18 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
18 verbose stack     at EventEmitter.emit (events.js:315:20)
18 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
18 verbose stack     at ChildProcess.emit (events.js:315:20)
18 verbose stack     at maybeClose (internal/child_process.js:1048:16)
18 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
19 verbose pkgid ed-app@0.0.0
20 verbose cwd /home/jde/edApp2Angular10Prerender2
21 verbose Linux 5.10.8-200.fc33.x86_64
22 verbose argv "/usr/bin/node" "/usr/local/bin/npm" "run" "build-prod-da"
23 verbose node v14.15.4
24 verbose npm  v6.14.11
25 error code ELIFECYCLE
26 error errno 1
27 error ed-app@0.0.0 build-prod-da: `ng build --prod --configuration=production-da`
27 error Exit status 1
28 error Failed at the ed-app@0.0.0 build-prod-da script.
28 error This is probably not a problem with npm. There is likely additional logging output above.
29 verbose exit [ 1, true ]

角.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "edApp": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "ed",
      "schematics": {
        "@schematics/angular:component": {
          "styleext": "scss"
        }
      },
      "i18n": {
        "sourceLocale":"en",
        "locales": {
          "da":"src/i18n/messages.da.xlf"
        }
      },
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/edApp",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets",
              "src/manifest.json",
              "src/apple-touch-icon.png",
              "src/browserconfig.xml",
              "src/favicon-16x16.png",
              "src/favicon-32x32.png",
              "src/mstile-150x150.png",
              "src/safari-pinned-tab.svg"
            ],
            "scripts": [ 
              "src/scripts/parallax.js"
            ],
            "styles": [
              {
                "input": "./node_modules/bootstrap/dist/css/bootstrap.css"
              },
              "./node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
              "src/styles.scss",
              "./node_modules/cropperjs/src/css/cropper.scss"
            ],
            "allowedCommonJsDependencies": [
              "crypto-js",
              "element-resize-detector",
              "batch-processor",
              "lodash"
            ]
          },
          "configurations": {
            "da": {
              "aot": true,
              "outputPath": "dist/da",
              "baseHref": "/da/",
              "localize":["da"]
            },
            "en": {
              "aot": true,
              "outputPath": "dist/en",
              "baseHref": "/en/",
              "localize":["en"]
          
            },
            "production-da-test": {
              "index": {
                "input": "src/index.test.da.html",
                "output": "index.html"
              },
              "outputPath": "dist-test",
              "localize":["da"],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "serviceWorker": true
            },
            "production-da": {
              "index": {
                "input": "src/index.prod.da.html",
                "output": "index.html"
              },
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "outputPath": "dist-prod/",
              "localize":["da"],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "serviceWorker": true
            },
            "production-en": {
              "index": {
                "input": "src/index.prod.en.html",
                "output": "index.html"
              },
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "outputPath": "dist-prod/",
              "baseHref": "/en/",
              "localize":["en"],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "serviceWorker": true
            },
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "serviceWorker": true
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "edApp:build",
            "proxyConfig": "proxy.conf.json",
            "disableHostCheck": true,
            "port":4300
          },
          "configurations": {
            "production-da": {
              "browserTarget": "edApp:build:production-da"
            },
            "production-en": {
              "browserTarget": "edApp:build:production-en"
            },
            "production": {
              "browserTarget": "edApp:build:production"
            },
            "en": {
              "browserTarget": "edApp:build:en"
            },
            "da": {
              "browserTarget": "edApp:build:da"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "edApp:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "karmaConfig": "src/karma.conf.js",
            "styles": [
              "src/styles.scss"
            ],
            "scripts": [],
            "assets": [
              "src/favicon.ico",
              "src/assets",
              "src/manifest.json"
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "edApp-e2e": {
      "root": "e2e/",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "edApp:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "edApp:serve:production"
            }
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": "e2e/tsconfig.e2e.json",
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "edApp"
}

包.json

{
  "name": "ed-app",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "before-build": "node prebuild.js",
    "extract-i18n": "ng xi18n --output-path i18n && xliffmerge --profile xliffmerge.json da en",
    "serve-da": "ng serve -o --configuration=da",
    "serve-en": "ng serve -o --configuration=en",
    "serve-da-home": "ng serve -o --configuration=da --host 0.0.0.0",
    "serve-en-home": "ng serve -o --configuration=en --host 0.0.0.0",
    "build-da": "ng build --configuration=da",
    "build-en": "ng build --configuration=en",
    "build-prod-da-test": "ng build --prod --configuration=production-da-test",
    "prebuild-prod-da": "npm run before-build",
    "prebuild-test-da": "npm run before-build",
    "build-test-da": "ng build --prod --configuration=production-da-test --crossOrigin=anonymous",
    "build-prod-da": "ng build --prod --configuration=production-da",
    "build-prod-en": "ng build --prod --configuration=production-en",
    "build-all": "for lang in da en; do npm run build-$lang; done",
    "build-prod-all": "for lang in da en; do npm run build-prod-$lang; done"
  },
  "browser": {
    "crypto": false
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^10.2.4",
    "@angular/cdk": "^10.2.7",
    "@angular/common": "^10.2.4",
    "@angular/compiler": "^10.2.4",
    "@angular/core": "^10.2.4",
    "@angular/forms": "^10.2.4",
    "@angular/localize": "^10.2.4",
    "@angular/platform-browser": "^10.2.4",
    "@angular/platform-browser-dynamic": "^10.2.4",
    "@angular/pwa": "^0.1000.8",
    "@angular/router": "^10.2.4",
    "@angular/service-worker": "^10.2.4",
    "@ckeditor/ckeditor5-angular": "^1.2.3",
    "@clampy-js/ngx-clampy": "^8.0.1",
    "@fortawesome/angular-fontawesome": "^0.7.0",
    "@fortawesome/fontawesome-svg-core": "^1.2.34",
    "@fortawesome/free-regular-svg-icons": "^5.15.2",
    "@fortawesome/free-solid-svg-icons": "^5.15.2",
    "@it-era/ngx-safe-pipes": "^0.2.1",
    "@ng-select/ng-select": "^5.1.0",
    "@ngx-pwa/local-storage": "^10.1.0",
    "@ngx-translate/core": "^13.0.0",
    "angular-file": "^3.4.0",
    "blueimp-canvas-to-blob": "^3.28.0",
    "body-scroll-lock": "^3.1.5",
    "bootstrap": "^4.6.0",
    "canvas-to-blob": "^1.0.0",
    "core-js": "^3.8.3",
    "cropperjs": "^1.5.9",
    "crypto-js": "^4.0.0",
    "element-resize-detector": "^1.2.1",
    "hammerjs": "^2.0.8",
    "heic-convert": "^1.2.4",
    "heic2any": "0.0.3",
    "lodash-es": "^4.17.20",
    "moment": "^2.29.1",
    "ng-sidebar": "^9.4.2",
    "ngx-bootstrap": "^5.6.2",
    "ngx-moment": "^5.0.0",
    "ngx-smart-modal": "^7.4.1",
    "ngx-spinner": "^10.0.1",
    "rxjs": "^6.6.3",
    "rxjs-tslint": "^0.1.8",
    "survey-angular": "^1.8.29",
    "zone.js": "^0.11.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.1000.8",
    "@angular/cli": "^10.2.2",
    "@angular/compiler-cli": "^10.2.4",
    "@angular/language-service": "^10.2.4",
    "@types/jasmine": "^3.6.3",
    "@types/jasminewd2": "^2.0.8",
    "@types/node": "^14.14.25",
    "codelyzer": "^6.0.1",
    "inquirer": "^7.3.3",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.2",
    "karma": "^5.2.3",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.3",
    "karma-jasmine": "~4.0.1",
    "karma-jasmine-html-reporter": "^1.5.4",
    "protractor": "^7.0.0",
    "replace-in-file": "^6.2.0",
    "ts-node": "^8.10.2",
    "tslint": "~6.1.3",
    "typescript": "^3.9.8"
  }
}
4

2 回答 2

1

您可以简单地target从更改es2015es5in tsconfig.ts

它将修复错误。

于 2021-11-07T11:58:55.550 回答
0

我最终升级到 Angular 11

然后我重新安装了所有软件包以重新开始。在那之后,还有一些包不是完全最新的,所以我使用 ncu (npm-check-updates) 来解决这个问题......

rm -rf node_modules package-lock.json
npm install
ncu -u
npm install

然后问题就消失了。我怀疑这可能是由于某种包版本不匹配或 Angular 10.2.4 的问题。

于 2021-02-10T23:14:32.150 回答