2016-11-14 208 views
2

通过文档页面上的AOT教程去后,我试图编译角2 AOT和我收到以下错误角AOT在编译失败(一些具有角/编译器,CLI)

"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 

我我在这一点上陷入困​​境。为什么angular/compiler-cli会抛出这个错误?

+0

我看到别人谁也有类似的错误,并从降级的2.2.1编译器CLI - > 2.1.0。我做了同样的事情,但现在我得到这个错误TypeError:无法读取对象的未定义 属性'AssetUrl'。 ' –

回答

1

正如你所说,它似乎是一个版本冲突。我遇到了同样的问题,必须重新安装该软件包才能使用指定的版本。我会建议安装发布版本并重新运行,直到你得到你想要的。对于它的价值,我有同样的错误,2.1.2为我工作。

npm install @angular/[email protected] --save-dev 

至于为什么,我会猜测包的版本不同步。尝试运行npm list --depth=0,看看是否有东西弹出。可能会暗示出什么是重击。

+0

是的,我最终再次尝试使用角度2.2.0和编译器CLi 2.2.0(就像现在的quickstart一样),它工作。有些东西是关闭的版本我不知道虽然 –

+0

谢谢!我试着解决这个问题比我大5岁。将我的应用升级到2.2.0(角度+编译器),发现了一个角度2错误,降低了角度,但将编译器保持在2.2.0 ..并忘记了它...谢谢! – Spock

1

我摆脱它的方式是使用2.2.0的所有角度包,包括编译器CLI。然后再次执行npm install以按照2.2.0重新加载所有程序包依赖关系,并且它工作正常。这里是的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",