Angular AOT Compiler - TypeError: this.compiler.analyzeModulesAsync is not a function

I am trying to execute compiler instructions in advance (AOT) here:

https://angular.io/guide/aot-compiler

The project I'm working on was developed using the quickstart sample, as described here:

https://angular.io/guide/setup

The project works fine without using the AOT compiler, but when I try to follow the instructions for the AOT compiler to work, I get the following error (this is on Windows 8):

C:\Users\zzzzz\Desktop\quickstart>"node_modules/.bin/ngc" -p ./src
TypeError: this.compiler.analyzeModulesAsync is not a function
    at CodeGenerator.codegen (C:\Users\zzzzz\Desktop\quickstart\node_modules\@angular\compiler-cli\src\codegen.js:32:14)
    at codegen (C:\Users\zzzzz\Desktop\quickstart\node_modules\@angular\compiler-cli\src\main.js:13:81)
    at Object.main (C:\Users\zzzzz\Desktop\quickstart\node_modules\@angular\tsc-wrapped\src\main.js:98:16)
    at main (C:\Users\zzzzz\Desktop\quickstart\node_modules\@angular\compiler-cli\src\main.js:19:16)
    at Object.<anonymous> (C:\Users\zzzzz\Desktop\quickstart\node_modules\@angular\compiler-cli\src\main.js:35:5)
    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)
Compilation failed

My package.json file looks like this:

{
  "name": "angular-quickstart",
  "version": "1.0.0",
  "description": "QuickStart package.json from the documentation, supplemented with testing support",
  "scripts": {
    "build": "tsc -p src/",
    "build:watch": "tsc -p src/ -w",
    "build:e2e": "tsc -p e2e/",
    "serve": "lite-server -c=bs-config.json",
    "serve:e2e": "lite-server -c=bs-config.e2e.json",
    "prestart": "npm run build",
    "start": "concurrently \"npm run build:watch\" \"npm run serve\"",
    "pree2e": "npm run build:e2e",
    "e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
    "preprotractor": "webdriver-manager update",
    "protractor": "protractor protractor.config.js",
    "pretest": "npm run build",
    "test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
    "pretest:once": "npm run build",
    "test:once": "karma start karma.conf.js --single-run",
    "lint": "tslint ./src/**/*.ts -t verbose"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@angular/common": "~4.0.0",
    "@angular/compiler": "~4.0.0",
    "@angular/compiler-cli": "^4.2.2",
    "@angular/core": "~4.0.0",
    "@angular/forms": "~4.0.0",
    "@angular/http": "~4.0.0",
    "@angular/platform-browser": "~4.0.0",
    "@angular/platform-browser-dynamic": "~4.0.0",
    "@angular/platform-server": "^4.2.2",
    "@angular/router": "~4.0.0",
    "@ngrx/core": "~1.2.0",
    "@ngrx/store": "~2.2.2",
    "angular-in-memory-web-api": "~0.3.0",
    "core-js": "^2.4.1",
    "rxjs": "5.0.1",
    "systemjs": "0.19.40",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@types/jasmine": "2.5.36",
    "@types/node": "^6.0.46",
    "canonical-path": "0.0.2",
    "concurrently": "^3.2.0",
    "jasmine-core": "~2.4.1",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "lite-server": "^2.2.2",
    "lodash": "^4.16.4",
    "protractor": "~4.0.14",
    "rimraf": "^2.5.4",
    "tslint": "^3.15.1",
    "typescript": "~2.1.0"
  },
  "repository": {}
}

When I check which version of @ angular / compiler I installed, I get 4.2.2, which seems to be the latest version:

C:\Users\zzzzz\Desktop\quickstart>npm view @angular/compiler version
4.2.2

Looking at the source in Github, I see that in angular / packages / compiler / src / aot / compiler.ts:

there is a function called analysisModulesAsync

https://github.com/angular/angular/blob/master/packages/compiler/src/aot/compiler.ts

However, when I do grep in my node_modules folder for analysisModulesAsync , I only see calls to this function. I do not see a definition for this. In fact, the class definition in compiler.d.ts has several differences from the compiler.ts file in Github.

I tried to “reinstall” by deleting the entire node_modules folder and restarting the npm installation and the error message would be the same.

I see a somewhat similar question here: Angular AOT error during compilation (something with angular / compiler-cli) , but I don’t know enough about npm versions to find out what might be due to a hit, or how to fix it.

, - - , - ?

@ angular/compiler-cli @angular/platform-server package.json. "~ 4.0.0", angular, node_modules npm install, .

, quickstart : npm install @angular/compiler-cli @angular/platform-server --save , .

+4
1

@Rolandus: , , aot , . 4.0.0 , ~, ^

+1

Source: https://habr.com/ru/post/1679359/


All Articles