Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I got an error while running dist file in nestjs project, please help me

(node:8356) UnhandledPromiseRejectionWarning: Error: No type definitions were found with the specified file name patterns: "./**/*.graphql". Please make sure there is at least one file that matches the given patterns.
    at GraphQLTypesLoader.<anonymous> (E:\NestJS\Template_Login\teample-api-backend-nestjs\backend\node_modules\@nestjs\graphql\dist\graphql-types.loader.js:38:23)
    at Generator.next (<anonymous>)
    at fulfilled (E:\NestJS\Template_Login\teample-api-backend-nestjs\backend\node_modules\tslib\tslib.js:114:62)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:8356) 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:8356) [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.
like image 320
BE Nestjs Avatar asked Sep 07 '25 00:09

BE Nestjs


2 Answers

I ran into the same issue. This is most likely caused by the fact that the .graphql files are ignored in build time and not copied to /dist. Interestingly, I didn't have that before and the build seemed to complete just fine, it appeared only today.

I found a workaround to the problem proposed by the NestJS creator: https://github.com/nestjs/graphql/issues/135

like image 160
Pramus Avatar answered Sep 09 '25 00:09

Pramus


https://docs.nestjs.com/cli/monorepo#assets

There is assets option in nestjs. This is the right way to do it in nestjs.

like image 28
Bright Lee Avatar answered Sep 08 '25 22:09

Bright Lee