0

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?

FoggyDay
  • 11,962
  • 4
  • 34
  • 48
L. Kvri
  • 1,456
  • 4
  • 23
  • 41
  • 1
    Does this answer your question? [How do I enable Ivy for Angular 8 or 9?](https://stackoverflow.com/questions/58522756/how-do-i-enable-ivy-for-angular-8-or-9) – FoggyDay Feb 19 '20 at 21:47
  • 1
    That tag should be `angular-ivy`, right? Not `ivy`. – andrewJames Feb 19 '20 at 22:30
  • As I saw no. I ran : npm i -g @angular/cli@next the result is the Angular version is 9.1.0-next.0 but the result is the same. – L. Kvri Feb 19 '20 at 23:03
  • May I ask you how do you mean "angular-ivy"? – L. Kvri Feb 19 '20 at 23:06
  • 1
    The question currently has three tags: `project`, `ivy`, and `angular9`. If you hover your mouse over the `ivy` tag, you will see a description which refers to a Java/Ant-related tool - nothing to do with Angular. There is a separate tag `angular-ivy` which specifically relates to an Angular compilation pipeline. I assume you want `angular-ivy` not `ivy`. The `ivy` tag brought me here :-) – andrewJames Feb 20 '20 at 00:21

1 Answers1

2
  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.

FoggyDay
  • 11,962
  • 4
  • 34
  • 48
  • I follow step by step the guide how to enable IVY for old angular application, but I always got error NG6002 – L. Kvri Feb 22 '20 at 19:26
  • 1) Since you're on Angular 9, you *DON'T* want to follow any steps that *AREN'T* for Angular 9. 2) Look here: https://github.com/angular/angular/issues/35399. Per the link: 3) `npm cache clean --force`. 4) `delete the top node_modules in the workspace (where you should have installed it), and rebuild libraries/apps.`. See also: https://github.com/angular/angular/pull/35191 – FoggyDay Feb 22 '20 at 21:10
  • Iknow, but before A9 my prj was on A8. Now on A9, no errors, but I switched on enableIvy and allowEmptyCodegenFiles I always got more error NG6002. Where can I found the description and cause of error NG6002? Thanks – L. Kvri Feb 23 '20 at 08:51
  • Sigh... You shouldn't have to "switch on" anything :( At least not if you start off with a brand new Angular 9 project. Regarding NG6002, look at my links. The issue seems to be "conflicts". An ideal solution is to "start clean". See my updates above. – FoggyDay Feb 23 '20 at 17:19
  • Originally I started to update my A8 project to A9. After it I switched on enableIvy and allowEmptyCodegenFiles I always got more error NG6002. When I always got the mentioned error came to my mind, if I create a new A9 project with IVY and move my old project content, it can be good also, this inspire my the how can I create new A9 project with IVY usage. – L. Kvri Feb 23 '20 at 20:18
  • Please 1) Read the links I cited, 2) Look at my updates, 3) Re-start your project from a "clean" install of Angular 9 and a "clean" Angular 9 project. – FoggyDay Feb 23 '20 at 22:50