Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 AoT ngc does not generate any files

When I run the offline compiler ngc on an Angular 2 RC5 vanilla project created by angular-cli, it does nothing.

Here's what I did

Setup:

ng new my-project
cd my-project
npm install @angular/compiler-cli typescript@next @angular/platform-server @angular/compiler

Running the compiler

./node_modules/.bin/ngc -p ./src

The command output nothing and I did not see it generate a min.ngfactory.ts

What am I missing?

like image 357
user6123723 Avatar asked Aug 26 '16 17:08

user6123723


People also ask

Does Angular use AOT by default?

By default, aot is set to true for new CLI applications. See the CLI command reference and Building and serving Angular apps for more information.

What is AOT compiler how do you enable it?

The Ahead of time compiler detects template error earlier. It detects and reports template binding errors during the build steps before users can see them. AOT provides better security. It compiles HTML components and templates into JavaScript files long before they are served into the client display.

What is NGC in Angular?

The Angular Compiler (which we call ngc ) is the tool used to compile Angular applications and libraries. ngc is built on the TypeScript compiler (called tsc ) and extends the process of compiling TypeScript code to add additional code generation related to Angular's capabilities.

How Angular is compiled?

ng-build: Compiles the application and produces the build files to an external folder. The name of the output folder is decided by the value of outputPath property present in the 'build' section in 'angular. json' file. As a result this output folder generated at the end can be used to deploy in any external server.


1 Answers

I encountered the same issue and I solved this by down grade typescript to 2.0.2.

I found this on: https://github.com/angular/angular/issues/11689

like image 100
1w2w3y Avatar answered Oct 10 '22 22:10

1w2w3y