react-email: Unable to view preview
Describe the Bug
I have a NextJs project and i want to integrate react-email. Thus, i use the Manual Setup option in the docs from step 2 to the end. Because i already have a script with dev, i use email: email dev --dir src/emails in the package.json script.
When i open the preview page on localhost:3001 and navigate to the only email i added from the docs, i get this error:
Error: Build failed with 4 errors: emails/my-email.tsx:1:29: ERROR: Could not resolve "@react-email/components" emails/my-email.tsx:7:6: ERROR: Could not resolve "react/jsx-runtime" emails/my-email.tsx:17:33: ERROR: [plugin: rendering-utilities-exporter] Failed trying to importrenderfrom either@react-email/renderor@react-email/componentsto be able to render your email template. Maybe you don't have either of them installed? emails/my-email.tsx:18:72: ERROR: Could not resolve "react"
Even after reinstalling the libraries it still doesnt work. I also tried the manual setup from scratch, exactly as it is in the docs and i get the same problem.
Here are my env details: MacOs 15.1.1 M3 Pro Chip Node v21.6.2 NPM 10.2.4 bun 1.0.26
Which package is affected (leave empty if unsure)
No response
Link to the code that reproduces this issue
none
To Reproduce
simply follow steps here: https://react.email/docs/getting-started/manual-setup
Expected Behavior
Preview for selected email should be displayed without a hustle.
What’s your node version? (if relevant)
21.6.2
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 16 (5 by maintainers)
I am having the same issue, tried to find the pnp file, didn’t find. Tried to create a project from zero, still having the same issue.
Many of the times I saw this error, while having all the packages installed, it was always because of an unwanted
.pnp.cjsfile at some place higher up from the project. Try looking up from the project, one directory at a time, while looking for a.pnp.cjsif there is one, delete it.I’m also facing the same issue but on WSL Ubuntu. However, it works on Windows 11.
I am still facing the same issue. Can’t find the
.pnp.cjsfile. @gabrielgrs Are you using bun? @gabrielmfern is your environment similar to the one i described above?This did the trick for me. Thank you @gabrielmfern!