Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nestjs ng-universal package dependency errors #1124

Open
3 of 15 tasks
Razorshnegax018 opened this issue Oct 20, 2023 · 6 comments
Open
3 of 15 tasks

Nestjs ng-universal package dependency errors #1124

Razorshnegax018 opened this issue Oct 20, 2023 · 6 comments

Comments

@Razorshnegax018
Copy link

Razorshnegax018 commented Oct 20, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

I'm trying to use nextjs with angular universal but I'm getting 3 dependency mismatch warnings, which is causing the whole nestjs application to fail. The problem is, I don't know which packages are the problem. All of the packages in my project are at the latest version and I'm using pnpm.

I'm fairly certain that these warnings are causing my application to fail, as the actual nestjs error that I get is an 'address in use' error which makes no sense. I just started up my computer how is localhost:4000 already in use?

Minimum reproduction code

Stackblitz example

Steps to reproduce

(from the above example)
Just run npm run dev:ssr

Note: The startup command is wrong, ctrl+c after packages are done installing

(From a fresh template)

  1. Create a new anguar project
  2. run ng add @nestjs/ng-universal
  3. npm run dev:ssr

Expected behavior

Build the nestjs application without any errors, allowing me to visit localhost

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

@nestjs/ng-universal

NestJS version

10.2.7

Packages versions

{
  "name": "northsea-shields",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test",
    "dev:ssr": "ng run northsea-shields:serve-ssr",
    "serve:ssr": "node dist/northsea-shields/server/main.js",
    "build:ssr": "ng build && ng run northsea-shields:server",
    "prerender": "ng run northsea-shields:prerender",
    "prebuild:ssr": "ngcc"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^16.2.9",
    "@angular/cdk": "^16.2.8",
    "@angular/common": "^16.2.9",
    "@angular/compiler": "^16.2.9",
    "@angular/core": "^16.2.9",
    "@angular/forms": "^16.2.9",
    "@angular/material": "^16.2.8",
    "@angular/platform-browser": "^16.2.9",
    "@angular/platform-browser-dynamic": "^16.2.9",
    "@angular/platform-server": "16.2.9",
    "@angular/router": "^16.2.9",
    "@nestjs/common": "^10.2.7",
    "@nestjs/core": "^10.2.7",
    "@nestjs/ng-universal": "8.0.0",
    "@nestjs/platform-express": "^10.2.7",
    "@ngrx/effects": "^16.3.0",
    "@ngrx/store": "^16.3.0",
    "@nguniversal/express-engine": "^16.2.0",
    "@stitches/core": "^1.2.8",
    "class-transformer": "^0.5.1",
    "class-validator": "^0.14.0",
    "express": "^4.18.2",
    "immer": "^10.0.3",
    "ngrx-immer": "^2.1.1",
    "reflect-metadata": "^0.1.13",
    "rxjs": "~7.8.1",
    "ssr-window": "^4.0.2",
    "tslib": "^2.6.2",
    "zone.js": "~0.13.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^16.2.6",
    "@angular/cli": "~16.2.6",
    "@angular/compiler-cli": "^16.2.9",
    "@nguniversal/builders": "^16.2.0",
    "@types/express": "^4.17.19",
    "@types/jasmine": "~5.1.0",
    "@types/node": "^20.8.6",
    "jasmine-core": "~5.1.1",
    "karma": "~6.4.2",
    "karma-chrome-launcher": "~3.2.0",
    "karma-coverage": "~2.2.1",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.1.0",
    "typescript": "~5.1.6"
  }
}

Node.js version

18.17.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

FULL ERROR LOG:

`

Build at: 2023-10-20T19:20:27.475Z - Hash: 7286de97f95b1151 - Time: 100389ms

./node_modules/.pnpm/@nestjs[email protected][email protected][email protected][email protected][email protected]/node_modules/@nestjs/common/utils/load-package.util.js:12:35-55 - Warning: Critical dependency: the request of a dependency is an expression

./node_modules/.pnpm/@nestjs+core@10.2.7_@nestjs+common@10.2.7_@nestjs[email protected][email protected][email protected]/node_modules/@nestjs/core/helpers/load-adapter.js:12:35-59 - Warning: Critical dependency: the request of a dependency is an expression

./node_modules/.pnpm/@nestjs+core@10.2.7_@nestjs+common@10.2.7_@nestjs[email protected][email protected][email protected]/node_modules/@nestjs/core/helpers/optional-require.js:9:35-55 - Warning: Critical dependency: the request of a dependency is an expression

// Problem warning end

Application bundle generation complete. [104.066 seconds]
Watch mode enabled. Watching for file changes...

Compiled successfully.
[Nest] 13803 - 10/20/2023, 2:20:31 PM LOG [NestFactory] Starting Nest application...
[Nest] 13803 - 10/20/2023, 2:20:31 PM LOG [NestFactory] Starting Nest application... +5ms
[Nest] 13803 - 10/20/2023, 2:20:31 PM LOG [InstanceLoader] AngularUniversalModule dependencies initialized +89ms
[Nest] 13803 - 10/20/2023, 2:20:31 PM LOG [InstanceLoader] AngularUniversalModule dependencies initialized +0ms
[Nest] 13803 - 10/20/2023, 2:20:31 PM LOG [InstanceLoader] AppModule dependencies initialized +0ms
[Nest] 13803 - 10/20/2023, 2:20:31 PM LOG [InstanceLoader] AppModule dependencies initialized +0ms
[Nest] 13803 - 10/20/2023, 2:20:31 PM LOG [RoutesResolver] ShipsController {/api/ships}: +51ms
[Nest] 13803 - 10/20/2023, 2:20:31 PM LOG [RouterExplorer] Mapped {/api/ships, GET} route +45ms
[Nest] 13803 - 10/20/2023, 2:20:31 PM LOG [RoutesResolver] ShipsController {/api/ships}: +2ms
[Nest] 13803 - 10/20/2023, 2:20:31 PM LOG [RouterExplorer] Mapped {/api/ships, GET} route +1ms
[Nest] 13803 - 10/20/2023, 2:20:31 PM LOG [NestApplication] Nest application successfully started +51ms
[Nest] 13803 - 10/20/2023, 2:20:31 PM LOG [NestApplication] Nest application successfully started +1ms
[Nest] 13803 - 10/20/2023, 2:20:31 PM ERROR [NestApplication] Error: listen EADDRINUSE: address already in use :::4000 +80ms

`

@Tony133
Copy link
Contributor

Tony133 commented Oct 21, 2023

Hi @Razorshnegax018 can you create a minimal reproduction in a cloneable git repository ?

@Razorshnegax018
Copy link
Author

Razorshnegax018 commented Oct 21, 2023

I added a stackblitz reproduction in the post, you can view it here

just run npm run dev:ssr and you'll get the warnings, then the application crashes

Sorry for the late reply

@Tony133
Copy link
Contributor

Tony133 commented Oct 22, 2023

Hi @Razorshnegax018,

I looked at the minimal reproduction that you created, but I can't reproduce the warnings messages and I can't find the npm run dev:ssr command I looked in the package.json that are in the minimal reproduction (see screenshot ) , but I can't find the command.

screen-1 screen-2

@Tony133
Copy link
Contributor

Tony133 commented Oct 22, 2023

However, I was able to reproduce the warnings you reported by creating a project from scratch, need to figure out if you need to make the corrections in the nest repository in these files (see screenshot) or in the ng-universal one

screen-warnings-ng-universal

@Tony133
Copy link
Contributor

Tony133 commented Oct 22, 2023

I also attach screenshot when running the following command npm run build:ssr:

screen-build-ssr

@Razorshnegax018
Copy link
Author

Hey @Tony133, I forgot to save the example code and now updated it with the ng-universal package and reproduces the error I'm talking about

Thanks for your help

@kamilmysliwiec kamilmysliwiec transferred this issue from nestjs/nest Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants