nestjs-notifications
nestjs-notifications copied to clipboard
Nest can't resolve dependencies of the NestJsNotificationsService
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);
}
}
}
Any solutions?
Any news?
I believe this because @nestjs/core
is listed as a hard dependency
https://github.com/edstevo/nestjs-notifications/blob/2e3da4320342719a63dd751a3fd9d958177ea61d/package.json?#L42
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 believe this because
@nestjs/core
is listed as a hard dependencyhttps://github.com/edstevo/nestjs-notifications/blob/2e3da4320342719a63dd751a3fd9d958177ea61d/package.json?#L42
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. 🤷♂️
@raqso are you using NestJS v7?
@raqso are you using NestJS v7?
No, 8 :/
could be that, even tho the peer deps allows v8
Any news? I have the same error in Nestjs 8 :/