dmitriy-nz / nestjs-form-data

NestJS middleware for handling multipart/form-data, which is primarily used for uploading files.
https://www.npmjs.com/package/nestjs-form-data
MIT License
125 stars 25 forks source link

Can't build project if using @FormDataRequest - Symbol() not available #1

Closed dantonyblanco closed 3 years ago

dantonyblanco commented 3 years ago

Bug Report

Current behavior

Can't build Nest app when adding @FormDataRequest decorator to @Post method in the controller.

Error message:

[ExceptionHandler] Nest can't resolve dependencies of the FormDataInterceptor (?, Reflector). Please make sure that the argument Symbol() at index [0] is available in the UserModule context.
Potential solutions:
app_1           | - If Symbol() is a provider, is it part of the current UserModule?
app_1           | - If Symbol() is exported from a separate @Module, is that module imported within UserModule?
app_1           |   @Module({
app_1           |     imports: [ /* the Module containing Symbol() */ ]
app_1           |   })|
 at Injector.lookupComponentInParentModules (/usr/src/app/node_modules/@nestjs/core/injector/injector.js:188:19)
app_1           |     at async Injector.resolveComponentInstance (/usr/src/app/node_modules/@nestjs/core/injector/injector.js:144:33)
app_1           |     at async resolveParam (/usr/src/app/node_modules/@nestjs/core/injector/injector.js:98:38)
app_1           |     at async Promise.all (index 0)
app_1           |     at async Injector.resolveConstructorParams (/usr/src/app/node_modules/@nestjs/core/injector/injector.js:113:27)
app_1           |     at async Injector.loadInstance (/usr/src/app/node_modules/@nestjs/core/injector/injector.js:46:9)
app_1           |     at async Injector.loadInjectable (/usr/src/app/node_modules/@nestjs/core/injector/injector.js:64:9)
app_1           |     at async Promise.all (index 6)
app_1           |     at async InstanceLoader.createInstancesOfInjectables (/usr/src/app/node_modules/@nestjs/core/injector/instance-loader.js:61:9)
app_1           |     at async /usr/src/app/node_modules/@nestjs/core/injector/instance-loader.js:29:13
app_1           |     at async Promise.all (index 4)
app_1           |     at async InstanceLoader.createInstances (/usr/src/app/node_modules/@nestjs/core/injector/instance-loader.js:27:9)
app_1           |     at async InstanceLoader.createInstancesOfDependencies (/usr/src/app/node_modules/@nestjs/core/injector/instance-loader.js:17:9)
app_1           |     at async /usr/src/app/node_modules/@nestjs/core/nest-factory.js:90:17
app_1           |     at async Function.asyncRun (/usr/src/app/node_modules/@nestjs/core/errors/exceptions-zone.js:18:13)
app_1           |     at async NestFactoryStatic.initialize (/usr/src/app/node_modules/@nestjs/core/nest-factory.js:88:13)

Expected Behavior

Build should work.

Nest version: 7.6.15
Typescript: 4.0.2
dantonyblanco commented 3 years ago

After trying a few things I realized the issue is solved when adding the import NestjsFormDataModule to the same module the controller was located in. Before this I only had NestjsFormDataModule as an import in the top-level app module

dantonyblanco commented 3 years ago

Might be a good idea to update the docs