I'm having a problem with my DIST folder in NestJS. For three days now, I've been trying to solve this issue without success.
Every time I implement the Swagger plugin in my application, it crashes and gives me the following error:
Error: Cannot find module 'C:/Users/csama/OneDrive/Desktop/Courses/Udemy/BackEnd/NestJS/loja-virtual-remake/src/users/entities/user.entity' Require stack:
- C:\Users\csama\OneDrive\Desktop\Courses\Udemy\BackEnd\NestJS\loja-virtual-remake\dist\src\users\users.controller.js
- C:\Users\csama\OneDrive\Desktop\Courses\Udemy\BackEnd\NestJS\loja-virtual-remake\dist\src\users\users.module.js
- C:\Users\csama\OneDrive\Desktop\Courses\Udemy\BackEnd\NestJS\loja-virtual-remake\dist\src\app.module.js
- C:\Users\csama\OneDrive\Desktop\Courses\Udemy\BackEnd\NestJS\loja-virtual-remake\dist\src\main.js at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1075:15) at Function.Module._load (node:internal/modules/cjs/loader:920:27) at Module.require (node:internal/modules/cjs/loader:1141:19) at require (node:internal/modules/cjs/helpers:110:18) at Object. (C:\Users\csama\OneDrive\Desktop\Courses\Udemy\BackEnd\NestJS\loja-virtual-remake\src\users\users.controller.ts:24:31) at Module._compile (node:internal/modules/cjs/loader:1254:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1308:10) at Module.load (node:internal/modules/cjs/loader:1117:32) at Function.Module._load (node:internal/modules/cjs/loader:958:12) at Module.require (node:internal/modules/cjs/loader:1141:19)
When I went to check the dist directory, I found that this line was causing the crash: openapi.ApiResponse({ status: common_1.HttpStatus.OK, type: require("C:/Users/csama/OneDrive/Desktop/Courses/Udemy/BackEnd/NestJS/loja-virtual-remake/src/users/entities/user.entity").UserEntity })
So, I made the following change to put "dist/src" instead, and it started working again. For example:
openapi.ApiResponse({ status: common_1.HttpStatus.CREATED, type: require("C:/Users/csama/OneDrive/Desktop/Courses/Udemy/BackEnd/NestJS/loja-virtual-remake/dist/src/users/entities/user.entity").UserEntity }) This error is caused by Swagger itself, which sets the wrong directory automatically.
Well, does anyone know how to solve this? I wouldn't want to always have to manually make these changes in the dist directory.
If someone wants to see the git code: https://github.com/Mayconyrp/BUG-Dist-Loja-Virtual
I deleted and recreated the CRUD + repository + entities for the user several times, redid the CLI, created various different combinations to set in the TypeScript file, hoping that it would reflect the correct directory in the 'dist'.