#Nest can't resolve dependencies of the paintingsRepository (?). Please make sure that the argument S

69 messages · Page 1 of 1 (latest)

west sierra
#

import { Module } from '@nestjs/common';
import { paintingscontroller } from './paintings.controller';
import { paintingsservice } from './paintings.service';
import { SequelizeModule } from '@nestjs/sequelize';
import { paintings } from './paintings.model';

@Module({
imports: [SequelizeModule.forFeature([paintings])],
controllers: [paintingscontroller],
providers: [paintingsservice],
exports: [paintingsservice],
})
export class paintingsModule { }

all modules are existing, yet still I continue to get this error again and again

#

Nest can't resolve dependencies of the paintingsRepository (?). Please make sure that the argument Sequelize at index [0] is available in the SequelizeModule context.

Potential solutions:

  • Is SequelizeModule a valid NestJS module?
  • If Sequelize is a provider, is it part of the current SequelizeModule?
  • If Sequelize is exported from a separate @Module, is that module imported within SequelizeModule?
    @Module({
    imports: [ /* the Module containing Sequelize */ ]
    })
fluid bison
#

For such kinda of errors, you need to show us two things: the module and the provider, so we can see how you’re injecting things

How that paintingService’s constructor looks like?

west sierra
#

full error

#

okay

#

one sec

#

so

#

the provider

#

import { Injectable } from '@nestjs/common';

@Injectable()
export class paintingsservice { }

#

and the module

#

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VERSION_NEUTRAL = exports.Scope = void 0;
const tslib_1 = require("tslib");
/*

  • Nest @common
  • Copyright(c) 2017 - 2023 Kamil Mysliwiec
  • https://nestjs.com
  • MIT Licensed
    */
    require("reflect-metadata");
    tslib_1.__exportStar(require("./decorators"), exports);
    tslib_1.__exportStar(require("./enums"), exports);
    tslib_1.__exportStar(require("./exceptions"), exports);
    tslib_1.__exportStar(require("./file-stream"), exports);
    var interfaces_1 = require("./interfaces");
    Object.defineProperty(exports, "Scope", { enumerable: true, get: function () { return interfaces_1.Scope; } });
    Object.defineProperty(exports, "VERSION_NEUTRAL", { enumerable: true, get: function () { return interfaces_1.VERSION_NEUTRAL; } });
    tslib_1.__exportStar(require("./module-utils"), exports);
    tslib_1.__exportStar(require("./pipes"), exports);
    tslib_1.__exportStar(require("./serializer"), exports);
    tslib_1.__exportStar(require("./services"), exports);
    tslib_1.__exportStar(require("./utils"), exports);
    heres nestjs/common module
#

and

#

heres sequelize module

#

use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
exports.__esModule = true;
__export(require("./dist"));

#

i can do stupid things cuz im learning backend for 4 days, so sorry

#

@fluid bison

fallow vergeBOT
#

Suggestion for @west sierra:
Please format your question with Markdown formatting.
It leads to better readability and an easier time to spot problems.
For code blocks, you can wrap your block with three back ticks before and after the block, and after the first three back ticks you can add a language (like ts) to add syntax highlighting.
e.g.

```ts
@Injectable()
export class MySuperAwesomeService {
constructor(@Inject('InjectionToken') private readonly dep: SomeDependency) {}

getRandomNumber(): number {
return Math.round(Math.random() * 1000);
}
}
```

Becomes

@Injectable()
export class MySuperAwesomeService {
  constructor(@Inject('InjectionToken') private readonly dep: SomeDependency) {}

  getRandomNumber(): number {
    return Math.round(Math.random() * 1000);
  }
}
fluid bison
#

you need to show us the source code, not the compiled JS version of it :p

west sierra
#

gotta fix it

#

sorry

fluid bison
#

the paintings.service.ts file, I guess

west sierra
#
import { Module } from '@nestjs/common';
import { paintingscontroller } from './paintings.controller';
import { paintingsservice } from './paintings.service';
import { SequelizeModule } from '@nestjs/sequelize';
import { paintings } from './paintings.model';

@Module({
  imports: [SequelizeModule.forFeature([paintings])],
  controllers: [paintingscontroller],
  providers: [paintingsservice],
  exports: [paintingsservice],
})
export class paintingsModule { }
#
import { Controller } from '@nestjs/common';

@Controller('paintings')
export class paintingscontroller { }
fluid bison
#

just the service with the error

#

oh, I see

#

the error says:
Nest can't resolve dependencies of the paintingsRepository (?). Please make sure that the argument Sequelize at index [0]

west sierra
#

yes

fluid bison
#

did you called SequelizeModule.forRoot somewhere?

west sierra
#

I dont think so

fluid bison
#

that's why

west sierra
#

The only time i operated SequelizeModule i did it in the @Module

fluid bison
#

the dynamic module SequelizeModule.forRoot is the one that allows you no register each module via SequelizeModule.forFeature, basically

west sierra
#

so

#

i need to go to the index file in sequelize

#

and add 'sequelizeModule.forRoot': true?

#

right?

fluid bison
#

Not sure. Follow the docs and you should be fine

#

I didn't use sequelize integration before

west sierra
#

okay

#

thank you

west sierra
#

oh hell na

#

still struggling

#

help

fluid bison
#

show us how your SequelizeModule.forRoot looks like now

west sierra
#

Attention, as i alr said im learning backend for 4 days, so dont be mad pls 😦

#
import { Module } from '@nestjs/common';
import { paintingscontroller } from './paintings.controller';
import { paintingsservice } from './paintings.service';
import { SequelizeModule } from '@nestjs/sequelize';
import { paintings } from './paintings.model';
@Module({
  imports: [SequelizeModule.forRoot({})]
})
@Module({
  imports: [SequelizeModule.forFeature([paintings])],
  controllers: [paintingscontroller],
  providers: [paintingsservice],
  exports: [paintingsservice],
})
export class paintingsModule { }```
#

ngl but i dont think theres something in docs that can help in this situation, at least i didnt found it yet

fluid bison
#

so you have 2 @Module? that's not valid, although not clear in the docs

west sierra
#

so yes

#

but i dont know what should i do otherwise

fluid bison
#

imports is an array

#

just add that SequelizeModule.forRoot to the array, you know

west sierra
#

oh

#

so like

import { Module } from '@nestjs/common';
import { paintingscontroller } from './paintings.controller';
import { paintingsservice } from './paintings.service';
import { SequelizeModule } from '@nestjs/sequelize';
import { paintings } from './paintings.model';

})
@Module({
  imports: [SequelizeModule.forRoot({}),SequelizeModule.forFeature([paintings])],
  controllers: [paintingscontroller],
  providers: [paintingsservice],
  exports: [paintingsservice],
})
export class paintingsModule { }
#

sorry

#

wait a sec gotta correct it

#

like that? or im dumb as hell?

#

oh

#

didnt work like that

#

oh

fluid bison
#

like I said, don't call @Module() twice

west sierra
#

it works

#

i deleted it

#

sorry forgot to correct it

#

it works

#

i just didnt saved it

#

bruh, but now i cant connect to my database T_T

#

but its solved