基于生产的Angular 构建存在严重问题

5ssjco0h  于 2021-09-13  发布在  Java
关注(0)|答案(0)|浏览(164)

我在angular 8中有一个应用程序,突然,我在生产中生成和部署的每个构建都开始抛出很多错误。
以下是与Angular 相关的依赖项:

"dependencies": {
    "@angular/animations": "~8.0.0",
    "@angular/common": "~8.0.0",
    "@angular/compiler": "~8.0.0",
    "@angular/core": "~8.0.0",
    "@angular/forms": "~8.0.0",
    "@angular/platform-browser": "~8.0.0",
    "@angular/platform-browser-dynamic": "~8.0.0",
    "@angular/router": "~8.0.0",

以下是与Angular 相关的开发依赖项:

"devDependencies": {
    "@angular-devkit/build-angular": "~0.800.0",
    "@angular/cli": "~8.0.2",
    "@angular/compiler-cli": "~8.0.0",
    "@angular/language-service": "~8.0.0",
    "@babel/core": "^7.3.4",
    "@storybook/angular": "^5.1.4",
    "@types/jasmine": "~3.3.13",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.0.8"

my angular.json生产配置:

"optimization": true,
              "outputHashing": "none",
              "sourceMap": true,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "5mb"
                }
              ]

我的tsconfig.json文件:

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "esnext",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types",
      "src/modules.d.ts"
    ],
    "lib": [
      "es2018",
      "dom"
    ],
    "paths": { "@angular/*": ["./node_modules/@angular/*"] }
  }
}

现在列出一些错误:

TypeError
f.ngDoCheck is not a function. (In 'f.ngDoCheck()', 'f.ngDoCheck' is undefined)

./node_modules/@angular/core/fesm5/core.js.pre-build-optimizer.js in checkAndUpdateNode at line 19344:19

    if ((def.flags & 65536 /* OnInit */) &&
        shouldCallLifecycleInitHook(view, 256 /* InitState_CallingOnInit */, def.nodeIndex)) {
        directive.ngOnInit();
    }
    if (def.flags & 262144 /* DoCheck */) {
        directive.ngDoCheck();
    }
    return changed;
Error
Uncaught (in promise): TypeError: Cannot read property 'call' of undefined
TypeError: Cannot read property 'call' of undefined
    at __webpack_require__ (URL)
    at ZoneDelegate.push../node_mod...

webpack/bootstrap in __webpack_require__ at line 83:1

            l: false,
            exports: {}
        };
        // Execute the module function
        modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
TypeError
this._delegate.applyChanges is not a function

./node_modules/@angular/common/fesm5/common.js.pre-build-optimizer.js in ngDoCheck at line 3832:30

            }
            else {
                var view = _this._viewContainer.get(adjustedPreviousIndex);
                _this._viewContainer.move(view, currentIndex);
                var tuple = new RecordViewTuple(item, view);
                insertTuples.push(tuple);

我试图解决问题的事情:
rm-rf package-lock.json和节点_模块以及npm i
更改“allowsyntheticdefaultimports”:true,在tsconfig.json中
将angular.json优化更改为false
将angular.json buildoptimizer更改为false
删除angular language service vs_代码扩展并重新安装依赖项
将Angular 依赖性更改为此,因为我认为它与https://github.com/ckeditor/ckeditor4-angular/issues/78

"devDependencies": { "@angular-devkit/architect": "~0.803.20", "@angular-devkit/build-angular": "~0.803.20", "@angular-devkit/core": "~8.3.20", "@angular-devkit/schematics": "~8.3.20", },

如果有人能帮助我,我会非常感激,我很绝望。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题