Search code examples
angularangular-aot

AoT Compilation Failed - no such file or directory, lstat 'tsconfig-aot.json'


Using the Setup demo project and following the instructions here, I get the following error when running node_modules/.bin/ngc -p tsconfig-aot.json:

Error: ENOENT: no such file or directory, lstat 'tsconfig-aot.json'
    at Object.fs.lstatSync (fs.js:947:11)
    at Object.main (/Users/EL-C/quickstart/node_modules/@angular/tsc-wrapped/src/main.js:59:21)
    at main (/Users/EL-C/quickstart/node_modules/@angular/compiler-cli/src/main.js:19:16)
    at Object.<anonymous> (/Users/EL-C/quickstart/node_modules/@angular/compiler-cli/src/main.js:35:5)
    at Module._compile (module.js:573:30)
    at Object.Module._extensions..js (module.js:584:10)
    at Module.load (module.js:507:32)
    at tryModuleLoad (module.js:470:12)
    at Function.Module._load (module.js:462:3)
    at Function.Module.runMain (module.js:609:10)
Compilation failed

I followed the instructions exactly and know the AoT file is there: tsconfig-aot in file structure

In case it's needed, here is the Package.json file:

{
  "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.3.4",
    "@angular/compiler": "~4.3.4",
    "@angular/compiler-cli": "^4.4.6",
    "@angular/core": "~4.3.4",
    "@angular/forms": "~4.3.4",
    "@angular/http": "~4.3.4",
    "@angular/platform-browser": "~4.3.4",
    "@angular/platform-browser-dynamic": "~4.3.4",
    "@angular/platform-server": "^4.4.6",
    "@angular/router": "~4.3.4",
    "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": {}
}

Why can't the ngc command find the file? Is this an issue with versioning? Is there a known bug? Google didn't reveal anything to me.


Solution

  • The path to the tsconfig-aot.json is not correct use this instead:

    node_modules/.bin/ngc -p ./src/app/tsconfig-aot.json