ReferenceError: path is not defined

The path module is a built-in module in Node.js, so you can use it directly without the need for an additional import.

Here’s the corrected code snippet:

// ...

const mailOptions = {
  // ...
  attachments: [
    {
      filename: file.originalname,
      path: require('path').resolve(file.path),
    },
  ],
};

// ...

By using require('path').resolve(file.path), the absolute path of the file will be resolved correctly.

Please make sure to save your changes and restart the server after making these adjustments. If you still encounter issues, please provide additional details or the relevant error message, and I’ll be glad to assist you further.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top