Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular prod build提供了对类型的引用,但没有变量错误_Angular_Angular Cli V8 - Fatal编程技术网

Angular prod build提供了对类型的引用,但没有变量错误

Angular prod build提供了对类型的引用,但没有变量错误,angular,angular-cli-v8,Angular,Angular Cli V8,一般来说,这是我制作angular 8应用程序的方式。然而,在我当前的应用程序中,它在编译时给了我一个错误 处于非法状态时出错:引用的类型没有变量{“filePath”:“/node_modules/@angular/router/router.d.ts”,“name”:“RouterLink”,“members”:[]} 建议快速搜索将生成优化器和aot标志设置为false。生成过程在执行以下操作时成功: ng build --configuration=production --base-h

一般来说,这是我制作angular 8应用程序的方式。然而,在我当前的应用程序中,它在编译时给了我一个错误

处于非法状态时出错:引用的类型没有变量{“filePath”:“/node_modules/@angular/router/router.d.ts”,“name”:“RouterLink”,“members”:[]}

建议快速搜索将
生成优化器
aot
标志设置为
false
。生成过程在执行以下操作时成功:

ng build --configuration=production --base-href /my-app/ --prod
我有两个问题:

  • 什么是
    指的是没有变量错误的类型
    问题?我 不介意分享我的代码,但无法理解代码的哪一部分 代码应该共享,因为我无法理解 错误

  • 可以将
    aot
    设置为false吗? 暗示

    AOT的性能改进非常重要,不容忽视

  • 我的package.json如下

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

    当然,你不应该关闭aot,非aot应用程序平均需要20秒才能打开手机。您能提供更多关于您使用的angular的确切版本的信息吗?解决此问题的方法是关闭模板的
    fullTemplateTypeCheck
    。这也很糟糕(模板上不会有类型检查),但至少不会破坏运行时性能设置
    fullTemplateTypeCheck
    to
    false
    编译时没有aot问题。谢谢你的意见。但仍在努力寻找实际问题。问题最有可能是在
    组件
    中使用
    routerLink
    指令,该组件属于未导入
    RouterModule
    模块?只需将RouterModule添加到该组件模块,错误就会消失
    
    {
      "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"
      }
    }