Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

604
Views
Nest can't resolve dependencies of the MongooseCoreModule (MongooseConnectionName, ?)

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

I am new to nest and am facing this issue, the app.controller.ts is

import { Module } from '@nestjs/common';
import { ItemsController } from './items.controller';
import { ItemsService } from './items.service';
import { MongooseModule } from '@nestjs/mongoose';
import { ItemSchema } from './schema/item.schema';

@Module({
  imports: [MongooseModule.forFeature([{name:'Item',schema:ItemSchema}])],
  controllers: [ItemsController],
  providers: [ItemsService],
})
export class ItemsModule {}

Any help would be appreciated

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

In you case, you can try to add this to your ItemSchema :

// schema/item.schema

@Schema({ collection: 'items' })

And make sure the import with a plural name :

// items.module.ts

// [...]
@Module({
  imports: [MongooseModule.forFeature([{name:'items',schema:ItemSchema}])],
  controllers: [ItemsController],
  providers: [ItemsService],
})
export class ItemsModule {}

According to this question.

Or if you prefer to keep the name schema name item, you can force it by following this answer

Mongoose is trying to be smart by making your collection name plural. You can however force it to be whatever you want:

var dataSchema = new Schema({..}, { collection: 'data' })

about 4 years ago · Juan Pablo Isaza Report

0

This error occurs when you dont start your code in the proper directory in your program folder. So cd navigate to the directory of your project and and run all the codes again.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!