I'm trying to use AOT compiler in this angular 2 project. I get error: TypeError: this.compiler.compileModules
is not a function when I execute command: "node_modules/.bin/ngc" -p tsconfig-aot.json
.
How to solve this issue?
Steps to reproduce:
clone this repo: https://github.com/AngularClass/angular2-webpack-starter
install compiler-cli (version 2.1.2): npm install @angular/compiler-cli --save
remove src/app/+detail
directory and detail
router from src/app/app.routes.ts
(I did it because "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
)
create 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
}
}
run "node_modules/.bin/ngc" -p tsconfig-aot.json
I just ran into the same issue and resolved it by making sure the "@angular/compiler": "2.1.1" and "@angular/compiler-cli" are using the same version number. e.g. "@angular/compiler-cli" should be "2.1.1" to match the compiler version.