Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Nest can't resolve dependencies of the FormDataInterceptor (?) #54

Open
VermilionB opened this issue Nov 24, 2023 · 4 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@VermilionB
Copy link

I tryed to use your library, but got an error:
Error: Nest can't resolve dependencies of the FormDataInterceptor (?). Please make sure that the argument Symbol(Inject token for NestJsFormData global configuration object) at index [0] is available in the BeatsModule context.

Here is my BeatsModule:

import { Module } from '@nestjs/common';
import { BeatsController } from './beats.controller';
import { BeatsService } from './beats.service';
import {PrismaService} from "../prisma.service";
import {FileUploadService} from "../file-upload/file-upload.service";
import {AvatarGeneratorService} from "../avatar_generator/avatar_generator.service";

@Module({
  controllers: [BeatsController],
  providers: [BeatsService, PrismaService, FileUploadService, AvatarGeneratorService]
})
export class BeatsModule {}
@dmitriy-nz
Copy link
Owner

Hi @VermilionB
Check if main the module is connected, add the NestjsFormDataModule to your BeatsModule in imports section.
Details in doc:

@wershest
Copy link

wershest commented Dec 5, 2023

I've got same error when I use NestjsFormDataModule.configAsync(). The NestjsFormDataModule.config() is ok.
This is my AppModule:

@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
      envFilePath: `.env.${process.env.NODE_ENV}`,
    }),
    MongooseModule.forRootAsync({
      inject: [ConfigService],
      useFactory: (config: ConfigService) => ({
        uri: config.get<string>('DB_URL'),
      }),
    }),
    // this is ok
    // NestjsFormDataModule.config({
    //   isGlobal: true,
    //   storage: FileSystemStoredFile,
    //   fileSystemStoragePath: '/tmp/nest-starter',
    // }),

    // configAsync cause errors
    NestjsFormDataModule.configAsync({
      inject: [ConfigService],
      useFactory: (config: ConfigService) => ({
        isGlobal: true,
        storage: FileSystemStoredFile,
        fileSystemStoragePath: config.get<string>('TEMP_DIR'),
      }),
    }),
    UsersModule,
    AuthModule,
  ],
  controllers: [],
  providers: [
    {
      provide: APP_PIPE,
      useValue: new ValidationPipe({ transform: true }),
    },
  ],
})
export class AppModule {}

Error: Nest can't resolve dependencies of the FormDataInterceptor (?). Please make sure that the argument Symbol(Inject token for NestJsFormData global configuration object) at index [0] is available in the UsersModule context.

@abriginets
Copy link

Hi @VermilionB Check if main the module is connected, add the NestjsFormDataModule to your BeatsModule in imports section. Details in doc:

Docs says it needs to be imported on the app level while in reality it's not global by default and needs to be imported on module basis.

@jamalahmed1122
Copy link

@wershest is correct, and i also solve the issue by using config instead of configAsync

@dmitriy-nz dmitriy-nz added the bug Something isn't working label Jun 23, 2024
@dmitriy-nz dmitriy-nz self-assigned this Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants