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

Nest can't resolve dependencies of the NestJsNotificationsService #4

Open
CamiloManrique opened this issue Sep 9, 2021 · 8 comments

Comments

@CamiloManrique
Copy link

I'm running into this error:

ERROR [ExceptionHandler] Nest can't resolve dependencies of the NestJsNotificationsService (?, NESTJS_NOTIFICATIONS_QUEUE, NESTJS_NOTIFICATIONS_JOB_OPTIONS). Please make sure that the argument ModuleRef at index [0] is available in the NestJsNotificationsModule context.

Potential solutions:
- If ModuleRef is a provider, is it part of the current NestJsNotificationsModule?
- If ModuleRef is exported from a separate @Module, is that module imported within NestJsNotificationsModule?
  @Module({
    imports: [ /* the Module containing ModuleRef */ ]
  })

My code:

app.module.ts

import { Module } from '@nestjs/common';
import {NestJsNotificationsModule} from "nestjs-notifications";
import AppService from "./app.service";

@Module({
    imports: [
      NestJsNotificationsModule.forRoot({}),
    ],
    providers: [
        AppService
    ]
})
export class AppModule {}

app.service.ts

import { Injectable } from "@nestjs/common";
import {LocalizationUpdateNotification} from "./modules/localization/notifications/localization-update.notification";
import {NestJsNotificationsService} from "nestjs-notifications";

@Injectable()
export default class AppService {

    private subscriptions: string[];

    constructor(private readonly notifications: NestJsNotificationsService) {
        this.subscriptions = [];
    }

    addSubscription(id: string) {
        this.subscriptions.push(id);
    }

    async sendNotifications(id, event) {
        if (this.subscriptions.includes(id)) {
            const notification = new LocalizationUpdateNotification({ id, event });
            await this.notifications.send(notification);
        }
    }
}
@houssenedao
Copy link

Any solutions?

@raqso
Copy link

raqso commented Dec 23, 2021

Any news?

@micalevisk
Copy link

micalevisk commented Dec 27, 2021

I believe this because @nestjs/core is listed as a hard dependency

"@nestjs/core": "^7.5.1",

You guys need to make this

.
├── package.json
├── src
└── node_modules
    ├── @nestjs
    │   ├── core
    │   └── common
    └── nestjs-notifications
        └── node_modules
            └── @nestjs
                ├── core
                └── common

looks like this instead:

.
├── package.json
├── src
└── node_modules
    ├── @nestjs
    │   ├── core
    │   └── common
    └── nestjs-notifications
        └── node_modules

@raqso
Copy link

raqso commented Dec 28, 2021

I believe this because @nestjs/core is listed as a hard dependency

"@nestjs/core": "^7.5.1",

You guys need to make this

.
├── package.json
├── src
└── node_modules
    ├── @nestjs
    │   ├── core
    │   └── common
    └── nestjs-notifications
        └── node_modules
            └── @nestjs
                ├── core
                └── common

looks like this instead:

.
├── package.json
├── src
└── node_modules
    ├── @nestjs
    │   ├── core
    │   └── common
    └── nestjs-notifications
        └── node_modules

I've tried this, but the error is still the same. 🤷‍♂️

@micalevisk
Copy link

@raqso are you using NestJS v7?

@raqso
Copy link

raqso commented Dec 28, 2021

@raqso are you using NestJS v7?

No, 8 :/

@micalevisk
Copy link

could be that, even tho the peer deps allows v8

@jmuller-oct
Copy link

jmuller-oct commented Mar 9, 2022

Any news? I have the same error in Nestjs 8 :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants