本文介绍了Angular AOT编译失败(Angular/compiler-cli出现问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

浏览完文档"页面上的AOT教程后,我试图编译angular 2 AOT并遇到以下错误

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

我现在被困住了.为何angular/compiler-cli会引发此错误?

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

推荐答案

正如您所说,这似乎是版本冲突.我遇到了同样的问题,必须重新安装该软件包才能使用指定的版本运行它.我建议安装发行版本并重新运行,直到获得所需的内容.就其价值而言,我遇到了同样的错误,而2.1.2为我工作.

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/[email protected] --save-dev

关于为什么,我推测这些软件包的版本不同步.尝试运行npm list --depth=0,看看是否弹出任何消息.可能会提示出什么不对劲.

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.

这篇关于Angular AOT编译失败(Angular/compiler-cli出现问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 04:49