swagger icon indicating copy to clipboard operation
swagger copied to clipboard

Cannot find module of external data type

Open AlejandroGonzalR opened this issue 3 years ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current behavior

Hi, I get a "Module not found" run-time error, precisely the following one when I start the server after build:

(node:2968) UnhandledPromiseRejectionWarning: ReferenceError: luxon is not defined
    at Object.type (/Users/alejandrogonzalez/Documents/GitHub/Backend/aggregate-sales/dist/src/entities/lead-order-incentive.entity.js:34:231)
    at SchemaObjectFactory.mergePropertyWithMetadata (/Users/alejandrogonzalez/Documents/GitHub/Backend/aggregate-sales/node_modules/@nestjs/swagger/dist/services/schema-object-factory.js:118:38)
    at /Users/alejandrogonzalez/Documents/GitHub/Backend/aggregate-sales/node_modules/@nestjs/swagger/dist/services/schema-object-factory.js:79:35
    at Array.map (<anonymous>)
    at SchemaObjectFactory.extractPropertiesFromType (/Users/alejandrogonzalez/Documents/GitHub/Backend/aggregate-sales/node_modules/@nestjs/swagger/dist/services/schema-object-factory.js:78:52)
    at SchemaObjectFactory.exploreModelSchema (/Users/alejandrogonzalez/Documents/GitHub/Backend/aggregate-sales/node_modules/@nestjs/swagger/dist/services/schema-object-factory.js:92:41)
    at /Users/alejandrogonzalez/Documents/GitHub/Backend/aggregate-sales/node_modules/@nestjs/swagger/dist/swagger-scanner.js:59:38
    at Array.forEach (<anonymous>)
    at SwaggerScanner.addExtraModels (/Users/alejandrogonzalez/Documents/GitHub/Backend/aggregate-sales/node_modules/@nestjs/swagger/dist/swagger-scanner.js:58:21)
    at SwaggerScanner.scanApplication (/Users/alejandrogonzalez/Documents/GitHub/Backend/aggregate-sales/node_modules/@nestjs/swagger/dist/swagger-scanner.js:42:14)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2968) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2968) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I tried to upgrade and also downgrade luxon as well as @nestjs/swagger version (keeping all of my @nestjs/* dependencies in sync), but nothing seems to work.

Minimum reproduction code

https://gist.github.com/AlejandroGonzalR/34b921317694234494aec577563dc363

Steps to reproduce

  1. npm i or npm ci in my main case.
  2. npm run apidocs (nest build && MODE=apidocs node dist/src/main).
  3. See error...

Expected behavior

I would expect the server to start without the error. I spent hours figuring out what's going on here, Typescript compilation and tests ran fine.

Package version

4.0.9

NestJS version

8.0.0

Node.js version

14.12.0

In which operating systems have you tested?

  • [X] macOS
  • [ ] Windows
  • [X] Linux

Other

No response

AlejandroGonzalR avatar May 11 '22 16:05 AlejandroGonzalR

Please provide a minimum reproduction repository (Git repository/StackBlitz/CodeSandbox project).

jmcdo29 avatar May 11 '22 17:05 jmcdo29

I use @ApiProperty({ type: () => String, }) as a workaround for this problem. If you really think about it, what is a DateTime from a HTTP point of view? there's no such thing. The endpoint expects an ISO string..

vlad-ostrovski avatar Sep 11 '22 11:09 vlad-ostrovski