Ild*_*dar 3 angular2-compiler angular2-cli angular
我正在尝试在这个Angular 2 项目中使用AOT编译器。当我执行命令时出现错误:不是一个函数:。如何解决这个问题?TypeError: this.compiler.compileModules"node_modules/.bin/ngc" -p tsconfig-aot.json
重现步骤:
克隆此存储库:https://github.com/AngularClass/angular2-webpack-starter
安装compiler-cli(版本2.1.2):npm install @angular/compiler-cli --save
从中删除src/app/+detail目录和detail路由器src/app/app.routes.ts(我这样做是因为"node_modules/.bin/ngc" -p tsconfig-aot.json输出错误can't resolve module src/app/+detail/index.ts from src/app/+detail/index.ts:)
创造tsconfig-aot.json:
{“compilerOptions”:{“target”:“es5”,“module”:“es2015”,“moduleResolution”:“node”,“sourceMap”:true,“emitDecoratorMetadata”:true,“experimentalDecorators”:true,“removeComments ": false, "noImplicitAny": true, "suppressImplicitAnyIndexErrors": true },
"angularCompilerOptions": { "genDir": "aot", "skipMetadataEmit" : true } }
跑步"node_modules/.bin/ngc" -p tsconfig-aot.json
小智 5
我刚刚遇到了同样的问题,并通过确保“@Angular/compiler”:“2.1.1”和“@Angular/compiler-cli”使用相同的版本号来解决它。例如“@angular/compiler-cli”应该是“2.1.1”以匹配编译器版本。
| 归档时间: |
|
| 查看次数: |
8622 次 |
| 最近记录: |