nestjs / ng-universal

Angular Universal module for Nest framework (node.js) 🌷

Home Page:https://nestjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Angular 13 + ng add @nestjs/ng-universal --force (Package installed failed)

lightzane opened this issue · comments

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Failed to install @nestjs/universal with error message in CLI

× Package install failed, 
C:\Users\user\path\to\project\name>ng add @nestjs/ng-universal --force
i Using package manager: npm
√ Found compatible package version: @nestjs/ng-universal@6.0.0.
√ Package information loaded.

The package @nestjs/ng-universal@6.0.0 will be installed and executed.
Would you like to proceed? Yes
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: test-nestjs-nguniversal@0.0.0
npm ERR! Found: rxjs@6.6.7
npm ERR! node_modules/rxjs
npm ERR!   rxjs@"~6.6.0" from the root project
npm ERR!   peer rxjs@"^6.5.3 || ^7.4.0" from @angular/common@13.2.2
npm ERR!   node_modules/@angular/common
npm ERR!     @angular/common@"~13.2.2" from the root project
npm ERR!     peer @angular/common@"^12.0.0 || ^13.0.0" from @nestjs/ng-universal@6.0.0
npm ERR!     node_modules/@nestjs/ng-universal
npm ERR!       @nestjs/ng-universal@"6.0.0" from the root project
npm ERR!     3 more (@angular/platform-server, @angular/platform-browser, @angular/platform-browser-dynamic)
npm ERR!   1 more (@angular/core)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer rxjs@"^7.1.0" from @nestjs/common@8.3.0
npm ERR! node_modules/@nestjs/common
npm ERR!   peer @nestjs/common@"^8.0.0" from @nestjs/ng-universal@6.0.0
npm ERR!   node_modules/@nestjs/ng-universal
npm ERR!     @nestjs/ng-universal@"6.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\user\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\user\AppData\Local\npm-cache\_logs\2022-02-15T01_30_02_329Z-debug.log
× Package install failed, see above.

Expected behavior

@nestjs/universal is successfully installed with Angular 13

Minimal reproduction of the problem with instructions

With @angular/cli@13

  1. ng new <project-name>
  2. ng add @nestjs/ng-universal --force (or --legacy-peer-deps or without --force)

Or with Angular 12 that just migrated to Angular 13

  1. ng new <project-name>
  2. npx @angular/cli@13 update @angular/core@13 @angular/cli@13 --force
  3. ng add @nestjs/ng-universal --force

What is the motivation / use case for changing the behavior?

Just adding @nestjs/universal with Angular 13

Environment


Nest version: X.Y.Z
@nestjs/ng-universal: 6.0.0

 
For Tooling issues:
- Node version: v14.16.0  
- Platform: Windows 



package.json

"dependencies": {
    "@angular/animations": "~13.2.2",
    "@angular/common": "~13.2.2",
    "@angular/compiler": "~13.2.2",
    "@angular/core": "~13.2.2",
    "@angular/forms": "~13.2.2",
    "@angular/platform-browser": "~13.2.2",
    "@angular/platform-browser-dynamic": "~13.2.2",
    "@angular/router": "~13.2.2",
    "rxjs": "~6.6.0",
    "tslib": "^2.2.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~13.2.3",
    "@angular/cli": "~13.2.3",
    "@angular/compiler-cli": "~13.2.2",
    "@types/jasmine": "~3.8.0",
    "@types/node": "^12.11.1",
    "jasmine-core": "~3.8.0",
    "karma": "~6.3.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "~1.7.0",
    "typescript": "~4.5.5"
  }
commented

I tried:

 $ npm config set legacy-peer-deps true
 $ ng add @nestjs/ng-universal

and it worked on me.
Although, I got an error later on as I run "dev:ssr / serve:ssr"

`..../server/main.js:370782
proxyRequestMethods(Index, '_index', IDBIndex, [
                                    ^
ReferenceError: IDBIndex is not defined
commented

I don't believe --force is an option of ng add.

The error is telling you that RxJS needs to be updated as a peer dependency of both Angular and Nest. Updating rxjs to at least 7.4.0 will fix this.

npm install rxjs@7.4.0
or
npm install rxjs@latest