I have NestJS api in NX workspace.
I created library "model" with user.ts:
export interface User{
name: string
}
export interface UserDto extends User {
email: string
}
user.controller.ts:
import { UserDto } from "@project/model";
@Post()
async create(@Req() req, @Res() res, @Body() user: UserDto): Promise<string>{
}
I'm getting build error:
C:\app\project\node_modules@nrwl\node\src\executors\node\node-with-require-overrides.js:16 return originalLoader.apply(this, arguments); ^ Error [ERR_REQUIRE_ESM]: require() of ES Module C:\app\project\node_modules@angular\core\fesm2015\core.mjs not supported. Instead change the require of C:\app\project\node_modules@angular\core\fesm2015\core.mjs to a dynamic import() which is available in all CommonJS modules.
But this works fine:
@Post()
async create(@Req() req, @Res() res): Promise<string>{
let user: UserDto = <UserDto>{};
}
When I created userDTO in NestJS project, it works. How to load entities or DTO from libraries to NestJS? Looks like the fault lies with the decorators.
Thanks