how to do server side rendering in angular14

189 Views Asked by At

I am trying to do server-side-rendering in my angular application created in version 14.I tried the command "ng add @nguniversal/[email protected]" at that time error occur. And the error is "ng add @nguniversal/[email protected] Skipping installation: Package already installed Schematic input does not validate against the Schema: {"project":"FLYBUILDS","appId":"serverApp","main":"main.server.ts","appDir":"app","rootModuleFileName":"app.server.module.ts","rootModuleClassName":"AppServerModule","skipInstall":true} Errors:

Data path "" must NOT have additional properties(appDir). " how to solve this error?

1

There are 1 best solutions below

2
On

If you're facing issues adding Angular Universal with Express Engine to an Angular 14 project, and encountering errors with the command:

ng add @nguniversal/[email protected]

Solution: I encountered a similar problem, and here's how I resolved it:

  1. Compatibility Check: Ensure that the versions of Angular Universal and Angular CLI are compatible with Angular 14

  2. Update Angular CLI: Update your Angular CLI to the latest version using the following command:

    npm install -g @angular/cli@latest
    
  3. Use Latest Angular Universal: Instead of specifying a version, try installing the latest version of Angular Universal:

    ng add @nguniversal/express-engine
    
  4. Clear npm Cache: Clear the npm cache to prevent potential caching issues:

    npm cache clean --force
    
  5. Retry Installation: After performing the above steps, try running the installation command again:

    ng add @nguniversal/express-engine
    

Hope this helps!