L. Kvri
L. Kvri

Reputation: 1703

How to create Angular 9 project with IVY?

How to create Angular 9 project with IVY?

I tried the following:

ng new sample9prjivy --enable-ivy

My environment:

Angular CLI: 9.0.2

Node: 12.16.0

OS: win32 x64

Angular: ... Ivy Workspace:

Package and Version

@angular-devkit/architect 0.900.2

@angular-devkit/core 9.0.2

@angular-devkit/schematics 9.0.2

@schematics/angular 9.0.2

@schematics/update 0.900.2

rxjs 6.5.3

C:\src\Angular\pilot\A9>ng new sample9prjivy --enable-ivy

Unknown option: '--enable-ivy'

What I missed?

Upvotes: 0

Views: 2575

Answers (1)

paulsm4
paulsm4

Reputation: 121599

  1. As an earlier poster tried to explain, there's no such "ng new" flag as --enable-ivy.

  2. As andrewjames explained above, the "ivy" tag is incorrect. You want "angular-ivy". I fixed it for you.

  3. If you want to enable Ivy for older Angular builds, read this thread: How do I enable Ivy for Angular 8 or 9?. You'll need to edit tsconfig.json and angular.json.

  4. It looks like Ivy is now the default for Angular 9:

https://angular.io/guide/ivy

Ivy is the code name for Angular's next-generation compilation and rendering pipeline. With the version 9 release of Angular, the new compiler and runtime instructions are used by default instead of the older compiler and runtime, known as View Engine.

  1. As the documentation discusses, there IS a flag for enableIvy ... but it's set in tsconfig.app.json. It is NOT a command line option for "ng new".

Update:

The answer to the OP's original question: you don't have to "create an Angular 9 project with Ivy": in Angular 9, Ivy should be enabled by default.

To answer the follow-on question about NG6002: look here (already cited below):

One final suggestion: it couldn't hurt to:

  1. Update Angular: ng update @angular/cli @angular/core
  2. Create a brand new project and copy the old source into the new project

Another Update

  1. Original problem: ng new sample9prjivy --enable-ivy =>

Unknown option: '--enable-ivy'

Cause: --enable-ivy simply isn't a legal "ng" option with Angular 9. Don't do it!

  1. Next problem: I always got more error NG6002

    This is a well-known issue upgrading existing projects to Angular 9. Look here and here. The basic issue is that "upgrading" the project can result in "inconsistencies". Both links suggest workarounds; I've also suggested some workarounds. I don't know if you've tried any of them yet :(

  2. CURRENT SUGGESTION:

    Since you don't seem to be making much progress, I'd suggest the following:

    a) UNINSTALL Angular: get a "clean version":

    npm uninstall -g @angular/cli
    npm cache clean
    npm cache verify
    npm install -g @angular/cli
    

    b) Confirm your "clean install" of Angular 9:

    ng --version
    ...
    Angular CLI: 9.0.3
    Node: 10.15.1
    OS: win32 x64
    
    Angular:
    ...
    Ivy Workspace:
    
    Package                      Version
    ------------------------------------------------------
    @angular-devkit/architect    0.900.3
    @angular-devkit/core         9.0.3
    @angular-devkit/schematics   9.0.3
    @schematics/angular          9.0.3
    @schematics/update           0.900.3
    rxjs                         6.5.3
    

    c) Create a brand new project with your "known good" Angular install.

    Do NOT change ANY configuration! Do NOT try to explicitly "enable Ivy"!

    d) Copy over your old source code (ONLY the project source code!) to your new project.

    e) Verify that "everything works".

    f) Post back what you find.

Upvotes: 1

Related Questions