【发布时间】:2020-09-03 04:27:57
【问题描述】:
我正在尝试配置this module。
完整的错误信息如下:
Nest can't resolve dependencies of the MailerService (?). Please make sure that the argument MAILER_OPTIONS at index [0] is available in the AppModule context.
我总是莫名其妙地收到这个错误,什么 MAILER_OPTIONS?这些选项在哪里?在这方面,文档中没有任何说明。完全不知道发生了什么。
这是我的 AppModule:
@Module({
imports: [
MailerModule.forRoot({
defaults: {
from: '"No Reply" <noreply@example.com>',
},
template: {
dir: path.join(process.env.PWD, 'templates/pages'),
adapter: new HandlebarsAdapter(),
options: {
strict: true,
},
},
options: {
partials: {
dir: path.join(process.env.PWD, 'templates/partials'),
options: {
strict: true,
},
},
},
}),
],
controllers: [AppController],
providers: [
AppService,
MailerService,
],
})
export class AppModule {}
有什么想法吗?
这是我正在使用的服务:
@Injectable()
export class AppService {
constructor(
private readonly mailerService: MailerService,
) {}
public async sendEmail(): Promise<any> {
const mailDetail: ISendMailOptions = {
to: 'gutgesagt@yahoo.co.uk',
from: 'noreply@nestjs.com',
subject: 'testing Nest MailerModule',
text: 'test test?!',
html: '<b>Yahooooo</b>',
};
return this.mailerService.sendMail(mailDetail);
}
}
【问题讨论】:
标签: javascript node.js typescript dependency-injection nestjs