angularangular-universal

ng generate universal issue with run command


I am using new @angular/cli 18.2.5. I did:

ng new my-app

Next:

ng add @nguniversal/express-engine

I got error "NOT SUPPORTED: keyword "id", use "$id" for schema ID") but the installation was successful.

And now I am trying:

1. ng generate universal --client-project=my-app

Error: Unknown argument: client-project

2. ng generate universal

Error: A collection and schematic is required during execution.

I follow this documentation: https://angulardive.com/blog/implementing-angular-universal-in-your-existing-angular-application/

I tested a lot of things, but can't find any solution for this. I am not sure if issue is releated to angular version (tried also angular 17), this error "NOT SUPPORTED: keyword "id", use "$id" for schema ID" or something else.


Solution

  • It seems like you're hitting a compatibility issue between @nguniversal/express-engine and Angular 18. Right now, nguniversal is expecting Angular v16 as a peer dependency. Downgrading to Angular 16 should solve the issue!

    When I tried to upgrade nguniversal, I got the following response :

    my-app>ng update @nguniversal/express-engine
    Using package manager: npm
    Collecting installed dependencies...
    Found 28 dependencies.
    Fetching dependency metadata from registry...
                      Package "@nguniversal/express-engine" has an incompatible peer dependency to "@angular/common" (requires "^16.0.0 || ^16.1.0-next.0", would install "18.2.5")
                      Package "@nguniversal/express-engine" has an incompatible peer dependency to "@angular/core" (requires "^16.0.0 || ^16.1.0-next.0", would install "18.2.5")
    × Migration failed: Incompatible peer dependencies found.
    Peer dependency warnings when installing dependencies means that those dependencies might not work correctly together.
    

    Also, I got the following response after downgrading the CLI's version to 16 :

    my-app>ng add @nguniversal/express-engine
    i Using package manager: npm
    √ Found compatible package version: @nguniversal/express-engine@16.2.0.
    √ Package information loaded.
    
    The package @nguniversal/express-engine@16.2.0 will be installed and
    executed.
    Would you like to proceed? Yes
    √ Packages successfully installed.