Kali
Kali

Reputation: 1

Nest can't resolve dependencies of the SequelizeCoreModule

I'm trying to import SequelizeModule in my app.module.ts but I got the following error:

[Nest] ERROR [ExceptionHandler] Nest can't resolve dependencies of the SequelizeCoreModule (SequelizeModuleOptions, ?). Please make sure that the argument ModuleRef at index [1] is available in the SequelizeCoreModule context.

app.module.ts

import { Module } from '@nestjs/common';
import { ModuleRef } from '@nestjs/core';
import { SequelizeModule } from '@nestjs/sequelize';
import { join } from 'path';

import { AppController } from './app.controller';
import { AppService } from './app.service';
import { TweetsController } from './tweets/tweets.controller';
import { TweetsModule } from './tweets/tweets.module';
import { TweetsService } from './tweets/tweets.service';

@Module({
  imports: [
    SequelizeModule.forRoot({
      dialect: 'sqlite',
      autoLoadModels: true,
      synchronize: true,
      host: join(__dirname, 'database.sqlite'),
    }),
    TweetsModule,
  ],
  controllers: [AppController, TweetsController],
  providers: [AppService, TweetsService],
})
export class AppModule {}

Upvotes: 0

Views: 2195

Answers (1)

Micael Levi
Micael Levi

Reputation: 6685

this happens when you have multiple nodejs modules loaded for the same @nestjs/core package. See them by running npm ls @nestjs/core. You can solve that by getting ride of those packages somehow and keeping only the one that your app depends on directly. Read the docs: https://docs.nestjs.com/faq/common-errors#cannot-resolve-dependency-error

Upvotes: 1

Related Questions