'Nest.js Type 'DynamicModule' is not assignable to type 'ForwardReference' on nest-modules/mailer
I have an Nest.js application. I wanted to add MailerModule to my app using following link -> https://npm.taobao.org/package/@nest-modules/mailer
However, I just did the following steps:
First, npm install --save @nest-modules/mailer
Second I add app module mail config but it is giving an error here is my app.module.ts:
import { Module } from '@nestjs/common';
import { HandlebarsAdapter, MailerModule } from '@nest-modules/mailer';
@Module({
imports: [
MailerModule.forRootAsync({
useFactory: () => ({
transport: 'smtps://[email protected]:[email protected]',
defaults: {
from:'"nest-modules" <[email protected]>',
},
template: {
dir: __dirname + '/templates',
adapter: new HandlebarsAdapter(), // or new PugAdapter()
options: {
strict: true,
},
},
}),
}),],
})
export class ApplicationModule {}
Now I can't compile because it is saying that :
TS2345: Argument of type '{ imports: DynamicModule[]; }' is not assignable to parameter of type 'ModuleMetadata'. Types of property 'imports' are incompatible. Type 'DynamicModule[]' is not assignable to type '(Type | DynamicModule | Promise | ForwardReference)[]'. Type 'DynamicModule' is not assignable to type 'Type | DynamicModule | Promise | ForwardReference'. Type 'DynamicModule' is not assignable to type 'ForwardReference'. Property 'forwardRef' is missing in type 'DynamicModule'.
Solution 1:[1]
Perhaps check what version of nest you're using, this issue may be resolved in versions of nestjs 6+:
Solution 2:[2]
I had a similar problem. I started to make a new project based on the old one. After installing the modules, this error appeared. The problem lay in private modules. They did not install without package-lock.json.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | chrismarx |
| Solution 2 | ??????? ?????? |
