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

The “path” argument must be of type string. Received undefined #47

Open
DoneDeal0 opened this issue Apr 15, 2021 · 3 comments
Open

Comments

@DoneDeal0
Copy link

When trying to send an email, the server crashes with this error:

err checkout TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined at new NodeError (node:internal/errors:329:5) at validateString (node:internal/validators:129:11) at Object.join (node:path:1081:7) at TemplateGenerator.render (/Users/myname/Desktop/Code/myapp/server/node_modules/nodemailer-express-handlebars/lib/generator.js:19:29) at /Users/myname/Desktop/Code/myapp/server/node_modules/nodemailer-express-handlebars/lib/index.js:9:19

The code is:

require("dotenv").config();
import nodemailer from "nodemailer";
import hbs from "nodemailer-express-handlebars";

const transporter = nodemailer.createTransport({
  service: "gmail",
  auth: {
    user: process.env.NODEMAILER_EMAIL,
    pass: process.env.NODEMAILER_PASSWORD,
  },
  tls: {
    rejectUnauthorized: false,
  },
});

transporter.use(
  "compile",
  hbs({
    viewEngine: "express-handlebars",
    viewPaths: "../mails/",
    extName: ".hbs",
  })
);

export class MailControler {
  static confirmSignup(
    { email, username },
    price: string
  ) {
    return transporter.sendMail({
      from: appMail,
      to: email,
      subject: "Hello",
      template: "confirmSignup",
      context: {
        username
      },
    });
  }
}

The route is working, the transporter is defined (I can log it in the terminal with the correct informations), the express-handlebars context is defined (I can also log the variable username), I can also log the process.env parts.

The structure is:

  • controler
    • mail.ts
  • mails
    • confirmSignup.hbs

So there is no directory error here.

Where is this undefined path argument?

@yads
Copy link
Owner

yads commented May 14, 2021

The argument to the plugin is viewPath not viewPaths.

@AprendiendoconGuillermo
Copy link

I use viewPath , but i have the same error, why...?

@yads
Copy link
Owner

yads commented Apr 5, 2022

I can't help you troubleshoot this with no info.

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

3 participants