Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the difference between "ng generate universal" and "ng add @nguniversal/express-engine"?

I am little bit confused by angular official doc. I was trying to learn how to use Angular universal to build something. But I saw this command in the doc:

ng add @nguniversal/express-engine

which is quoted from https://angular.io/guide/universal.

But AFAIK there is another command called "ng generate universal".

To my guess.., ng generate universal is part of ng add @nguniversal/express-engine(am I right?), So what is the main difference between those two commands?

like image 625
Mizok.H Avatar asked Dec 05 '25 20:12

Mizok.H


1 Answers

ng add is a schematic that first installs the @nguniversal/express-engine here. That will provide your local ng CLI with some extra commands - one of which is ng generate universal. It will do so by installing the npm package (and potentially adjusting some of your local files).

ng universal is another schematic, which will (with the help of the newly installed package from the previous step) create the universal app.

Think about what happens when you, e.g. ng add @angular/material.

That installs the @angular/material package (and updates your project files by modifying package.json and maybe other stuff).

With those installed, you can now generate material components, e.g. table or a dashboard.

It's the same here. They're different schematics - at a very abstract level, they do the same thing - modify files in your project directory), but specifically "add" has a different job then "generate".

like image 157
Zlatko Avatar answered Dec 08 '25 12:12

Zlatko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!