3

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:

  1. clone this repo: https://github.com/AngularClass/angular2-webpack-starter

  2. install compiler-cli (version 2.1.2): npm install @angular/compiler-cli --save

  3. 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)

  4. 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 } }

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

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

2 Comments

yes, the same issue and same solution, it seems @angular/compiler and @angular/compiler-cli shoud strictly be the same version, in my case 2.1.2
And what to do if the same issue is producing in angular@4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.