I have a problem in angular when using the command npm run build: ssr

Viewed 904

I have a project in angular 10, and I wanted to add universal angular. everything ok when executing the command (ng add @ nguniversal / express-engine), but then when executing build ssr I get an error in console. this is my current configuration in my package.json

{
  "name": "myproject",
  "version": "0.0.1",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "dev:ssr": "ng run myproject:serve-ssr",
    "serve:ssr": "node dist/myproject/server/main.js",
    "build:ssr": "ng build --prod && ng run myproject:server:production",
    "prerender": "ng run myproject:prerender"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~10.0.2",
    "@angular/cdk": "~10.0.1",
    "@angular/common": "~10.0.2",
    "@angular/compiler": "~10.0.2",
    "@angular/core": "~10.0.2",
    "@angular/forms": "~10.0.2",
    "@angular/platform-browser": "~10.0.2",
    "@angular/platform-browser-dynamic": "~10.0.2",
    "@angular/platform-server": "~10.0.2",
    "@angular/router": "~10.0.2",
    "@ng-select/ng-option-highlight": "0.0.4",
    "@ng-select/ng-select": "^3.7.1",
    "@nguniversal/express-engine": "^10.0.1",
    "angular2-text-mask": "^9.0.0",
    "core-js": "^3.6.1",
    "crypto-js": "^3.3.0",
    "express": "^4.15.2",
    "ng2-currency-mask": "^5.3.1",
    "ngx-store": "^2.1.0",
    "popper.js": "1.16.0",
    "rxjs": "~6.5.5",
    "tslib": "^2.0.0",
    "zone.js": "~0.10.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1000.0",
    "@angular/cli": "~10.0.0",
    "@angular/compiler-cli": "~10.0.2",
    "@angular/language-service": "~10.0.2",
    "@nguniversal/builders": "^10.0.1",
    "@types/express": "^4.17.0",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~3.3.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "^3.9.5"
  }
}

I have been searching for the solution to this problem but could not find the answer. What am I doing wrong? What configuration do I need?

ERROR in The target entry-point "@nguniversal/express-engine" has missing dependencies:
 - @angular/platform-server

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myproject@0.1.0 build:ssr: `ng build --prod && ng run myproject:server:production`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myproject@0.1.0 build:ssr script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\jfern\AppData\Roaming\npm-cache\_logs\2020-07-03T23_42_56_145Z-debug.log
0 Answers
Related