2

After going through the AOT tutorial on the Docs page, I am trying to compile angular 2 AOT and am getting the following error

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

TypeError: compiler.AnimationParser is not a constructor
at Function.CodeGenerator.create (C:\Projects\NeilKellyClient4\node_modules\@angular\compiler-cli\src\codegen.js:108:400)
at codegen (C:\Projects\NeilKellyClient4\node_modules\@angular\compiler-cli\src\main.js:7:36)
at Object.main (C:\Projects\NeilKellyClient4\node_modules\@angular\tsc-wrapped\src\main.js:37:16)
at Object.<anonymous> (C:\Projects\NeilKellyClient4\node_modules\@angular\compiler-cli\src\main.js:16:9)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
Compilation failed

I am getting stuck at this point. Any reason why angular/compiler-cli is throwing this error ?

Kevin Quiring
  • 639
  • 1
  • 11
  • 26
  • I saw someone who had a similar error and downgraded their compiler-cli from 2.2.1 -> 2.1.0. I did the same thing but now I am getting this error `TypeError: Cannot read property 'AssetUrl' of undefined at Object. ` – Kevin Quiring Nov 15 '16 at 00:08

2 Answers2

1

As you say, it appears to be a version conflict. I had the same issue, and had to reinstall the package to get it to work, with the version specified. I would suggest installing the release versions and re-running until you get what you wanted. For what it's worth, I had same error, and 2.1.2 worked for me.

npm install @angular/compiler-cli@2.1.2 --save-dev

As to why, I would speculate the package versions are out of sync. Try running npm list --depth=0 and see if anything pops up. Might give a hint as to what's out of whack.

Fiddles
  • 2,790
  • 1
  • 32
  • 35
  • Yeah I ended up trying it again with angular 2.2.0 and compiler-cli 2.2.0 (like the quickstart is as of today.) and it worked. Something was off with versions I don't know what though – Kevin Quiring Nov 15 '16 at 04:23
  • Thank you! I got 5 years older trying to solve this. Upgraded my app to 2.2.0 (angular + compiler), discovered an angular2 bug, downgraded angular but kept the compiler at 2.2.0.. and forgot about it... thank you! – Spock Nov 16 '16 at 11:17
1

The way I got rid of it was using 2.2.0 for all the angular packages including compiler-cli. Then did npm install again to reload all package dependencies as per 2.2.0 and it worked. Here is a part of package.json:

"dependencies": {
    "@angular/common": "~2.2.0",
    "@angular/compiler": "~2.2.0",
    "@angular/compiler-cli": "^2.2.0",
    "@angular/core": "~2.2.0",
    "@angular/forms": "~2.2.0",
    "@angular/http": "~2.2.0",
    "@angular/platform-browser": "~2.2.0",
    "@angular/platform-browser-dynamic": "~2.2.0",
    "@angular/platform-server": "^2.2.0",
    "@angular/router": "~3.2.0",
    "@angular/upgrade": "~2.2.0",
Peter
  • 10,492
  • 21
  • 82
  • 132