Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Universal does not add the necessary files

I try to use the command ng add @nguniversal/express-engine, but I only get this message:

Skipping installation: Package already installed NOT SUPPORTED: keyword “id”, use “$id” for schema ID

and no files that should add like server.ts are not adding.

I am uploading the current package.json:

{
  "name": "respondo-chat",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "dist": "http-server ./www/",
    "build:staging": "ng build --configuration=staging"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "16.2.4",
    "@angular/cdk": "^16.2.3",
    "@angular/common": "16.2.4",
    "@angular/compiler": "16.2.4",
    "@angular/core": "16.2.4",
    "@angular/forms": "16.2.4",
    "@angular/material": "^16.2.3",
    "@angular/platform-browser": "16.2.4",
    "@angular/platform-browser-dynamic": "16.2.4",
    "@nguniversal/express-engine": "^16.2.0",
    "@ngx-translate/core": "^15.0.0",
    "@ngx-translate/http-loader": "^8.0.0",
    "clientjs": "^0.2.1",
    "file-saver": "2.0.2",
    "ngx-uploader": "^17.0.1",
    "rxjs": "^7.8.1",
    "socket.io-client": "2.3.1",
    "tslib": "^2.0.0",
    "zone.js": "~0.13.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^16.2.1",
    "@angular/cli": "16.2.1",
    "@angular/compiler-cli": "16.2.4",
    "@angular/localize": "16.2.4",
    "@schematics/angular": "10.1.2",
    "@types/jasmine": "~3.6.0",
    "@types/jasminewd2": "2.0.3",
    "@types/node": "16.18.119",
    "@types/socket.io-client": "1.4.34",
    "codelyzer": "^6.0.0",
    "http-server": "0.12.3",
    "jasmine-core": "^5.0.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "6.4.1",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "7.0.0",
    "ts-node": "8.3.0",
    "tslint": "6.1.0",
    "typescript": "5.1.6"
  }
}

So that the necessary files related to ssr are added to my project.

like image 834
Dominik Modrzejewski Avatar asked Jan 18 '26 08:01

Dominik Modrzejewski


1 Answers

This is happening as Angular Universal (@nguniversal) has become part of Angular CLI repo from Angular 17 onwards.

Migration Reference: https://github.com/angular/universal

Even though you are using Angular 16 in your project (Which allows @nguniversal), your CLI must be of latest version (17 or above).


To add SSR support to Angular 16 Project, downgrade your Angular CLI to 16 and install @nguniversal/express-engine.

Reference: https://v16.angular.io/guide/universal


To add SSR support to Angular 17 Project use:

ng add @angular/ssr

Reference: https://v17.angular.io/guide/ssr

like image 193
Web Developer in Pune Avatar answered Jan 20 '26 22:01

Web Developer in Pune