简体   繁体   English

Angular 8 ng build --prod 在“Injectable”的模板编译期间给出错误

[英]Angular 8 ng build --prod gives Error during template compile of 'Injectable'

I upgraded from angular 6 to 8 and updated all the libraries used in the project.我从 angular 6 升级到 8 并更新了项目中使用的所有库。 Everything seems to be running fine but when I use ng build --prod, I get these errors一切似乎都运行良好,但是当我使用 ng build --prod 时,出现这些错误

ERROR in Error during template compile of 'Injectable'
  Function calls are not supported in decorators but 'ɵmakeDecorator' was called.
Error during template compile of 'Directive'
  Function calls are not supported in decorators but 'ɵmakeDecorator' was called.
Error during template compile of 'NgModule'
  Function calls are not supported in decorators but 'ɵmakeDecorator' was called.
Error during template compile of 'Injectable'
  Function calls are not supported in decorators but 'ɵmakeDecorator' was called.
Error during template compile of 'Injectable'
  Function calls are not supported in decorators but 'ɵmakeDecorator' was called.
Error during template compile of 'Injectable'
  Function calls are not supported in decorators but 'ɵmakeDecorator' was called.
Error during template compile of 'Injectable'
  Function calls are not supported in decorators but 'ɵmakeDecorator' was called.
Error during template compile of 'Injectable'
  Function calls are not supported in decorators but 'ɵmakeDecorator' was called.
Error during template compile of 'Injectable'
  Function calls are not supported in decorators but 'ɵmakeDecorator' was called.
Error during template compile of 'Injectable'
  Function calls are not supported in decorators but 'ɵmakeDecorator' was called.
Error during template compile of 'NgModule'
  Function calls are not supported in decorators but 'ɵmakeDecorator' was called.
Error during template compile of 'Injectable'
  Function calls are not supported in decorators but 'ɵmakeDecorator' was called.

I already searched for solutions and got things like changing absolute path to relative.我已经搜索了解决方案并得到了诸如将绝对路径更改为相对路径之类的东西。 I did that still I get these issues我这样做了,但我仍然遇到这些问题

Here is package.json这是 package.json

{
  "name": "centilytics-frontend",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@amcharts/amcharts3-angular": "^2.1.1",
    "@amcharts/amcharts4": "^4.5.6",
    "@amcharts/amcharts4-geodata": "^4.1.6",
    "@angular/animations": "^8.1.1",
    "@angular/cdk": "^8.1.1",
    "@angular/common": "~8.1.1",
    "@angular/compiler": "~8.1.1",
    "@angular/core": "~8.1.1",
    "@angular/forms": "~8.1.1",
    "@angular/material": "^8.1.1",
    "@angular/platform-browser": "~8.1.1",
    "@angular/platform-browser-dynamic": "~8.1.1",
    "@angular/router": "~8.1.1",
    "@ng-bootstrap/ng-bootstrap": "^5.0.0",
    "@sedeh/wizard-storage": "^1.2.5",
    "@types/jquery": "^3.3.30",
    "ag-grid": "^18.1.2",
    "ag-grid-angular": "^21.0.1",
    "ag-grid-community": "^21.0.1",
    "aws-mqtt": "^0.2.2",
    "aws-sdk": "^2.289.0",
    "classlist.js": "^1.1.20150312",
    "jquery": "^3.4.1",
    "ng5-slider": "^1.2.4",
    "ngx-bootstrap": "^5.1.0",
    "ngx-editor": "^4.1.0",
    "ngx-gauge": "^1.0.0-beta.10",
    "ngx-mat-select-search": "^1.7.6",
    "ngx-summernote": "^0.6.5",
    "paho-mqtt": "^1.0.4",
    "rxjs": "~6.4.0",
    "tslib": "^1.9.0",
    "values.js": "^1.0.3",
    "web-animations-js": "^2.3.2",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.801.1",
    "@angular/cli": "~8.1.1",
    "@angular/compiler-cli": "~8.1.1",
    "@angular/language-service": "~8.1.1",
    "@types/node": "~8.9.4",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "^5.0.0",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.4.3"
  }
}

Adding this to tsconfig.json worked for me将此添加到 tsconfig.json 对我有用

"compilerOptions": {
    "paths": {
        "@angular/*": [ "node_modules/@angular/*"]
    }
  }

There is a regression (a behavior that used to work and stopped working in a new release) open ticket for this issue.此问题有一个回归(过去在新版本中工作并停止工作的行为)开放票证。 And under that issue there is the solution: https://github.com/angular/angular/issues/23609#issuecomment-386876693在该问题下有解决方案: https : //github.com/angular/angular/issues/23609#issuecomment-386876693

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

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