gpt4 book ai didi

angular - Angular 2 提前编译中的未知编译器选项 'angularCompilerOptions'

转载 作者:行者123 更新时间:2023-12-02 04:04:03 31 4
gpt4 key购买 nike

我正在尝试使用 AOT编译器 this Angular 2项目。我得到错误: TypeError: this.compiler.compileModules is not a function when I execute command: "node_modules/.bin/ngc"-p tsconfig-aot.json 。如何解决这个问题?

重现步骤:

  1. 克隆此存储库:https://github.com/AngularClass/angular2-webpack-starter

  2. 安装 compiler-cli(版本 2.1.2):npm install @angular/compiler-cli --save

  3. src/app/app.routes.ts 中删除 src/app/+detail 目录和 detail 路由器(我这样做是因为"node_modules/.bin/ngc"-p tsconfig-aot.json outputs error: can't resolve module src/app/+detail/index.ts from src/app/+detail/index.ts)

  4. 创建 tsconfig-aot.json:

    { “编译器选项”:{ “目标”:“ES5”, “模块”:“es2015”, "moduleResolution": "节点", “源 map ”:真实的, “emitDecoratorMetadata”:真实的, “experimentalDecorators”:真实的, “删除评论”:假的, “noImplicitAny”:是的, "suppressImplicitAnyIndexErrors": true },
    “angularCompilerOptions”:{ "genDir": "aot", “skipMetadataEmit”:真 }

  5. 运行 "node_modules/.bin/ngc"-p tsconfig-aot.json

最佳答案

我刚刚遇到了同样的问题,并通过确保 "@angular/compiler": "2.1.1"和 "@angular/compiler-cli"使用相同的版本号来解决它。例如“@angular/compiler-cli”应为“2.1.1”以匹配编译器版本。

关于angular - Angular 2 提前编译中的未知编译器选项 'angularCompilerOptions',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40407132/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com