在浏览了Docs页面上的AOT教程之后,我正在尝试编译角2 AOT,并得到以下错误
"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我被困在这点上了。为什么角/编译器-cli会抛出这个错误?
发布于 2016-11-15 01:04:03
正如你所说,这似乎是一个版本冲突。我也有同样的问题,必须重新安装包才能让它工作,并指定版本。我建议安装发行版并重新运行,直到你得到你想要的。值得的是,我也犯了同样的错误,2.1.2为我工作。
npm install @angular/compiler-cli@2.1.2 --save-dev至于为什么,我会推测包版本不同步。尝试运行npm list --depth=0并查看是否有任何弹出。可能会暗示出什么是不正常的。
发布于 2016-11-17 09:05:32
我摆脱它的方法是对所有的角包使用2.2.0,包括编译器-cli。然后,按照2.2.0的要求,再次执行npm install来重新加载所有包依赖项,并且它工作了。下面是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",https://stackoverflow.com/questions/40599035
复制相似问题