react-email
react-email copied to clipboard
Errors while importing Email template in Node
Describe the Bug
Bug Description
I am facing an issue while integrating the email functionality using @react-email/render
and nodemailer
packages. The code crashes with an "ERR_MODULE_NOT_FOUND" error.
Actual Behavior
The code crashes with an "ERR_MODULE_NOT_FOUND" error. The error message indicates that a specific module is not found. Error: module not found at ... ...
Environment
- Node.js version:
-
@react-email/render
version: -
nodemailer
version:
Additional Information
- Any modifications or customizations made to the email template or code.
- Any relevant configuration settings or environment variables used.
- Any other details or observations that could be helpful.
// Code snippet or relevant configurations
import User from '../schemas/User.schema.js';
import { Email } from '../emails/email';
import { render } from '@react-email/render';
const userRoute = async (fastify) => {
const giftHTML = render(Email);
fastify.post('/', async (request, reply) => {
try {
const userData = request.body
// Create a new user object based on the received data
const user = new User(userData)
Which package is affected (leave empty if unsure)
No response
Link to the code that reproduces this issue
https://react.email/docs/integrations/nodemailer#3-convert-to-html-and-send-email
To Reproduce
Steps to Reproduce
- Install dependencies:
@react-email/render
andnodemailer
. - Create an email template using React in a
.jsx
or.tsx
file. - Import the email template, convert it to HTML, and send the email using Nodemailer.
- Execute the code and observe the crash with the "ERR_MODULE_NOT_FOUND" error.
Expected Behavior
Expected Behavior
This is what react-email says on their docs to convert emails into html with node js
``
What's your node version? (if relevant)
No response
Same issue, node v 18.14.0
Hey! I'm facing the same issue! Is there any update on this?
Hey @joaopcm, since you were the last one to comment here, could you make a minimal reproduction repo of this?
Hey @joaopcm, since you were the last one to comment here, could you make a minimal reproduction repo of this?
Hey, @gabrielmfern! Thank you for reminding me I left this comment in this thread! I found the solution and shared it here. My issue was more about supporting React.js components in a Node.js environment using a NestJS project.
Hey, I am also difficulty in using react-email components in nodejs server. Is it possible to import react-email components in express sever to send emails?
Hey, I am also difficulty in using react-email components in nodejs server. Is it possible to import react-email components in express sever to send emails?
Hey, @Nithishprem! I believe I had a similar issue. I was using NestJS (which uses Express as the main API engine) with TypeScript. As I'm using SWC to build my project, I needed to add the proper configurations to support JSX/TSX files when compiling the project. Have you already tried something similar to this?
same issue node v18.17.0
Hey @joaopcm!
Both links you provided redirect to a twitter (X) post that doesn't have any comments or solutions present. Were you able to find a solution to the above issue? I have been stuck on it for longer than I care to admit 😅
Hey @joaopcm!
Both links you provided redirect to a twitter (X) post that doesn't have any comments or solutions present. Were you able to find a solution to the above issue? I have been stuck on it for longer than I care to admit 😅
@LockeandDropit, this is what I see when I open the X link ↓
No able to find the solution, I have tried so many things already and nothing could make it work properly...
@gusmagnago Could you make a reproduction of it? Seems to me that everyone having this issue here is having it for different reasons.
It could be that you might have something misconfigured, as @joaopcm did.
We're having issues too getting our NestJS backend to use React Email to send out emails.
@basememara Would you be willing to share a minimal reproduction of it? With one I can help you for sure.