我正在尝试按照angular.io网站上的AOT编译指南,但是当我执行下面显示的命令时, " node_modules /的.bin / NGC" -p tsconfig-aot.json
我收到错误
TypeError: compiler.createAotCompiler is not a function
at Function.CodeGenerator.create (path\node_modules\@angular\compiler-cli\src\codegen.js:78:36)
at codegen (path\node_modules\@angular\compiler-cli\src\main.js:7:36)
at Object.main (path\node_modules\@angular\tsc-wrapped\src\main.js:37:16)
at Object.<anonymous> (path\node_modules\@angular\compiler-cli\src\main.js:14:9)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
Compilation failed
我的角度依赖项与编译器版本匹配(^ 2.1.2)
"dependencies": {
"@angular/common": "~2.2.2",
"@angular/compiler": "^2.1.2",
"@angular/compiler-cli": "^2.2.2",
"@angular/core": "~2.2.2",
"@angular/forms": "~2.2.2",
"@angular/http": "~2.2.2",
"@angular/platform-browser": "~2.2.2",
"@angular/platform-browser-dynamic": "~2.2.2",
"@angular/platform-server": "^2.2.2",
"@angular/router": "~3.2.2",
"@angular/upgrade": "~2.2.2",
"@types/core-js": "^0.9.34",
"@types/jasmine": "^2.5.36",
"@types/node": "^6.0.46",
"@types/selenium-webdriver": "^2.53.33",
"@webcomponents/custom-elements": "1.0.0-alpha.3",
"angular": "^1.5.8",
"browser-sync": "^2.12.3",
"clarity-angular": "^0.7.0",
"clarity-icons": "^0.7.0",
"clarity-ui": "^0.7.0",
"codelyzer": "^1.0.0-beta.3",
"connect-history-api-fallback": "^1.2.0",
"core-js": "^2.4.0",
"del": "^2.2.0",
"gulp": "^3.9.1",
"gulp-autoprefixer": "^3.1.0",
"gulp-concat": "^2.6.0",
"gulp-env": "^0.4.0",
"gulp-inline-ng2-template": "^4.0.0",
"gulp-preprocess": "^2.0.0",
"gulp-sass": "^2.3.0",
"gulp-sourcemaps": "^2.2.0",
"gulp-tslint": "^7.0.1",
"gulp-typescript": "^3.1.2",
"gulp-util": "^3.0.7",
"jasmine-core": "^2.4.1",
"jasmine-spec-reporter": "^2.4.0",
"karma": "^1.3.0",
"karma-coverage": "^1.1.0",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.0",
"karma-spec-reporter": "0.0.26",
"mutationobserver-shim": "^0.3.2",
"phantomjs-prebuilt": "^2.1.7",
"protractor": "^4.0.9",
"reflect-metadata": "^0.1.8",
"remap-istanbul": "^0.7.0",
"run-sequence": "^1.2.1",
"rxjs": "5.0.0-rc.4",
"systemjs": "0.19.41",
"systemjs-builder": "^0.15.16",
"tslint": "^4.0.1",
"typescript": "^2.0.3",
"web-animations-js": "^2.2.1",
"zone.js": "^0.7.1"
答案 0 :(得分:1)
这与版本有关,所有角度依赖都应该是相同的版本,在你的情况下很好,尝试删除 node_modules 文件夹并执行 npm install 强>
这是我的文件看起来和工作正常的方式
"@angular/common": "^2.2.2",
"@angular/compiler": "^2.2.2",
"@angular/compiler-cli": "^2.2.2",
"@angular/core": "^2.2.2",
"@angular/forms": "^2.2.2",
"@angular/http": "^2.2.2",
"@angular/platform-browser": "^2.2.2",
"@angular/platform-browser-dynamic": "^2.2.2",
"@angular/platform-server": "^2.2.2",
"@angular/router": "^3.2.2",