Closed krivochenko closed 6 years ago
Hi @krivochenko, It's related with this issue and will be fixed soon, thanks for reporting
Looks like it wasn't fixed:
const mailerTransport = nodemailer.createTransport({
sendmail: true,
newline: 'unix',
path: '/usr/sbin/sendmail',
});
@Module({
imports: [
MailerModule.forRoot({
transport: mailerTransport,
defaults: {
from: config.get('mailer.from'),
},
templateDir: './templates/mailer',
}),
...
$ node index.js
[Nest] 1828 - 2018-9-6 16:20:59 [Application] Converting circular structure to JSON
TypeError: Converting circular structure to JSON
at JSON.stringify (<anonymous>)
at ModuleTokenFactory.getDynamicMetadataToken (/srv/project/backend/node_modules/@nestjs/core/injector/module-token-factory.js:17:45)
at ModuleTokenFactory.create (/srv/project/backend/node_modules/@nestjs/core/injector/module-token-factory.js:11:27)
at ModuleCompiler.compile (/srv/project/backend/node_modules/@nestjs/core/injector/compiler.js:19:47)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:118:7)
at Function.Module.runMain (module.js:692:11)
at startup (bootstrap_node.js:194:16)
at bootstrap_node.js:666:3
1: node::Abort() [node]
2: 0x8cea99 [node]
3: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [node]
4: 0xb1444c [node]
5: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [node]
6: 0x154bbd1842fd
Aborted
error Command failed with exit code 134.
nest version: 5.2.0
Looks like it wasn't fixed:
const mailerTransport = nodemailer.createTransport({ sendmail: true, newline: 'unix', path: '/usr/sbin/sendmail', }); @Module({ imports: [ MailerModule.forRoot({ transport: mailerTransport, defaults: { from: config.get('mailer.from'), }, templateDir: './templates/mailer', }), ...
$ node index.js [Nest] 1828 - 2018-9-6 16:20:59 [Application] Converting circular structure to JSON TypeError: Converting circular structure to JSON at JSON.stringify (<anonymous>) at ModuleTokenFactory.getDynamicMetadataToken (/srv/project/backend/node_modules/@nestjs/core/injector/module-token-factory.js:17:45) at ModuleTokenFactory.create (/srv/project/backend/node_modules/@nestjs/core/injector/module-token-factory.js:11:27) at ModuleCompiler.compile (/srv/project/backend/node_modules/@nestjs/core/injector/compiler.js:19:47) at <anonymous> at process._tickCallback (internal/process/next_tick.js:118:7) at Function.Module.runMain (module.js:692:11) at startup (bootstrap_node.js:194:16) at bootstrap_node.js:666:3 1: node::Abort() [node] 2: 0x8cea99 [node] 3: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [node] 4: 0xb1444c [node] 5: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [node] 6: 0x154bbd1842fd Aborted error Command failed with exit code 134.
nest version: 5.2.0
Hello @anyx! You're making the same mistake that I!
Instead of:
const mailerTransport = nodemailer.createTransport({
sendmail: true,
newline: 'unix',
path: '/usr/sbin/sendmail',
});
@Module({
imports: [
MailerModule.forRoot({
transport: mailerTransport,
defaults: {
from: config.get('mailer.from'),
},
templateDir: './templates/mailer',
}),
...
You should do:
const mailerTransport = {
sendmail: true,
newline: 'unix',
path: '/usr/sbin/sendmail',
};
@Module({
imports: [
MailerModule.forRoot({
transport: mailerTransport,
defaults: {
from: config.get('mailer.from'),
},
templateDir: './templates/mailer',
}),
...
The reason is that because in this line: https://github.com/nest-modules/mailer/blob/4de893c48fe776398828ea994ca117c5ecb03c57/lib/mailer.provider.ts, mailerProvider already calls createTransport.
@cdiaz I think that we can improve docs with examples for different plugins, if you agree I would like to submit a new PR to that!
Hello @RafaelTCostella , your PR will be welcome, feel free to contribute. Thanks
Solved in v 0.4.1
Thanks for your work, but I encountered issue:
Steps for reproducing:
@Module({ imports: [ MailerModule.forRoot(), ], controllers: [AppController], components: [], }) export class AppModule {}
import * as mandrillTransport from 'nodemailer-mandrill-transport';
export = { transport: mandrillTransport({ auth: { api_key: 'key' } }), defaults: { from:'"nest-mailer" noreply@nestjs.com', }, templateDir: './src/common/email-templates' }