#TypeOrmModule and controller import order issue

8 messages Β· Page 1 of 1 (latest)

slim swallow
#

At app.module I import app.controller first, after that I import TypeOrmModule module. It makes Param Decorators in @nestjs/common like @quasi kiln, @Query, @Param,... return undefined value.
Let me show you how I use import in app.module:

import { AppController } from './app.controller';
import { TypeOrmModule } from '@nestjs/typeorm';

By changing this two line order ParamDecorators work correctly.

import { TypeOrmModule } from '@nestjs/typeorm';
import { AppController } from './app.controller';

I havn't seen this issue with other imported modules like: ConfigModules. HttpModule.

Any body is here that faced with this issue before?

sleek boneBOT
#

Please run the command npx -y @nestjs/cli info and paste the output in a code block. This will help us determine if there is a version issue in your packages and which version of nest we are triaging.

slim swallow
#
[System Information]
OS Version     : Linux 6.5.0-21-generic
NodeJS Version : v20.10.0
NPM Version    : 10.3.0 

[Nest CLI]
Nest CLI Version : 10.3.2 

[Nest Platform Information]
platform-express version : 10.3.3
schematics version       : 10.1.1
swagger version          : 7.3.0
typeorm version          : 10.0.2
testing version          : 10.3.3
common version           : 10.3.3
config version           : 3.2.0
axios version            : 3.0.2
core version             : 10.3.3
cli version              : 10.3.2
lime sierra
#

Okay, and npm ls reflect-metadata?

slim swallow
#

β”œβ”€β”¬ @nestjs/[email protected]
β”‚ └── [email protected] deduped
β”œβ”€β”¬ @nestjs/[email protected]
β”‚ └── [email protected] deduped
β”œβ”€β”¬ @nestjs/[email protected]
β”‚ β”œβ”€β”¬ @nestjs/[email protected]
β”‚ β”‚ └── [email protected] deduped
β”‚ └── [email protected] deduped
β”œβ”€β”¬ @nestjs/[email protected]
β”‚ └── [email protected] deduped
β”œβ”€β”€ [email protected]
└─┬ [email protected]
└── [email protected]

lime sierra
slim swallow
#

It fix the problem.
What is reflect-metadata?

lime sierra
#

reflect-metadata is the package that allows for the typescript metadata from the decorators to be easily read and used. TypeORM recently updated to 0.2.1 an d Nest is compatible with it, but installs 0.1.14 by default, so you ahve to update it so they use the same version