0

I am learning the Angular 2, following this https://angular.io/docs/ts/latest/cookbook/aot-compiler.html

And use this command to compile my app.

"node_modules/.bin/ngc" -p tsconfig-aot.json

However, I got just node_modules generated, nothing from my app. enter image description here

It appears this is an issue, can you help a walk around an alternative solution?

and here are the tsconfig-aot.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "es2015",
    "moduleResolution": "node",
    "outDir": "./aot",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [ "es2015", "dom" ],
    "removeComments": false,
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true,
    "types": []
  },

  "files": [
    "app/app.module.ts",
    "app/main.ts"
  ],

  "angularCompilerOptions": {
    "genDir": "./aot",
    "skipMetadataEmit": true
  }
}

//https://github.com/angular/angular/issues/11689

and package.json

{
  "name": "angular2-quickstart",
  "version": "1.0.0",
  "scripts": {
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
    "lite": "lite-server",
    "postinstall": "typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings"
  },
  "license": "ISC",
  "dependencies": {
    "@angular/common": "^2.2.3",
    "@angular/compiler": "^2.2.3",
    "@angular/compiler-cli": "^2.2.3",
    "@angular/core": "^2.2.3",
    "@angular/forms": "^2.2.3",
    "@angular/http": "^2.2.3",
    "@angular/platform-browser": "^2.2.3",
    "@angular/platform-browser-dynamic": "^2.2.3",
    "@angular/platform-server": "^2.2.3",
    "@angular/router": "^3.2.3",
    "@angular/upgrade": "^2.2.3",
    "bootstrap": "^3.3.6",
    "core-js": "^2.4.1",
    "reflect-metadata": "^0.1.3",
    "rxjs": "^5.0.0-rc.4",
    "systemjs": "^0.19.41",
    "typescript": "^2.0.10",
    "typings": "^1.5.0",
    "zone.js": "^0.6.23"
  },
  "devDependencies": {
    "concurrently": "^2.2.0",
    "lite-server": "^2.2.2",
    "typescript": "^2.0.2",
    "typings": "^1.3.2"
  }
}

Edited: I search around, someone advises downgrading the type script to 2.0.10 helps, but this doesn't work to me.

I am using Windows 7

khoailang
  • 725
  • 1
  • 15
  • 32

1 Answers1

1

I doubt there's an alternative solution to this since the angular compiler basically wraps the typescript compiler. I haven't had a chance to try this in angular v2.4.0, but this could be fixed in that version of the angular compiler.

If you're still stuck in angular v2.2.3, then downgrading typescript to 2.0.10 does work. In your packages.json make sure the typescript dependency version is specified like this:

"devDependencies": {
  ...
  "typescript": "~2.0.10",
  ...
}

or for that specific version, like this:

"devDependencies": {
  ...
  "typescript": "2.0.10",
  ...
}

In your example you specified a caret range, so npm got the latest version that has a major version of 2, i.e. 2.1.x. https://docs.npmjs.com/misc/semver#caret-ranges-123-025-004

Derek
  • 967
  • 1
  • 9
  • 16
  • 1
    In my case I needed to downgrade to 2.0.2. Just to let you know. – eko Dec 30 '16 at 04:44
  • thanks Daryl and echomax, I switch to use the Angular2 CLI, it works perfectly to me. I didn't try your suggestion yet, but your comment about the "caret-ranges" really helps – khoailang Jan 17 '17 at 10:10