4
ng build --configuration=production --base-href /my-app/ --prod

通常这是我为生产构建 angular 8 应用程序的方式。但是在我当前的应用程序中,它在编译时给了我一个错误。

非法状态下的错误:引用没有变量的类型 {"filePath":"/node_modules/@angular/router/router.d.ts","name":"RouterLink","members":[]}

快速搜索建议将build-optimizer&aot标志设置为false. 构建过程在执行时成功:

ng build --configuration=production --base-href /my-app/ --prod --build-optimizer=false --aot=false

我有两个疑问:

  1. 问题是什么referring to a type without a variable error?我不介意共享我的代码,但由于我无法理解错误的相关性,因此无法理解应该共享代码的哪一部分。

  2. 设置aot为false可以吗?一个中型博客 建议

    AOT 的性能改进非常显着,不容忽视

我的 package.json 如下

{
  "name": "my-app",
  "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": {
    "@angular/animations": "~8.2.0",
    "@angular/common": "~8.2.0",
    "@angular/compiler": "~8.2.0",
    "@angular/core": "~8.2.0",
    "@angular/fire": "^5.2.1",
    "@angular/forms": "~8.2.0",
    "@angular/material": "^8.1.4",
    "@angular/platform-browser": "~8.2.0",
    "@angular/platform-browser-dynamic": "~8.2.0",
    "@angular/router": "~8.2.0",
    "ag-grid-angular": "^21.2.1",
    "ag-grid-community": "^21.2.1",
    "ag-grid-enterprise": "^21.2.1",
    "angular-persistence": "^1.0.1",
    "firebase": "^6.5.0",
    "ng-zorro-antd": "^8.2.1",
    "rxjs": "^6.5.2",
    "rxjs-compat": "^6.5.3",
    "tslib": "^1.10.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.802.2",
    "@angular/cli": "~8.2.2",
    "@angular/compiler-cli": "~8.2.0",
    "@angular/language-service": "~8.2.0",
    "@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.5.3"
  }
}
4

0 回答 0