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

Unable to view preview #1815

Open
iampapagray opened this issue Dec 12, 2024 · 8 comments
Open

Unable to view preview #1815

iampapagray opened this issue Dec 12, 2024 · 8 comments
Labels
App: Preview Package: react-email This is the CLI we generally use as just `email` on the temrinal. Resolution: Needs More Information More information is needed on this issue Type: Bug Confirmed bug

Comments

@iampapagray
Copy link

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.

Screenshot 2024-12-12 at 22 44 25

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

@iampapagray iampapagray added the Type: Bug Confirmed bug label Dec 12, 2024
@mjacquin
Copy link

Same issue here 😞
Any advices ?

@iampapagray
Copy link
Author

@mjacquin Nothing so far. I'm stuck

@gabrielmfern
Copy link
Collaborator

Many of the times I saw this error, while having all the packages installed, it was always because of an unwanted .pnp.cjs file at some place higher up from the project. Try looking up from the project, one directory at a time, while looking for a .pnp.cjs if there is one, delete it.

@haase1020
Copy link

Many of the times I saw this error, while having all the packages installed, it was always because of an unwanted .pnp.cjs file at some place higher up from the project. Try looking up from the project, one directory at a time, while looking for a .pnp.cjs if there is one, delete it.

This did the trick for me. Thank you @gabrielmfern!

@gabrielmfern gabrielmfern added Package: react-email This is the CLI we generally use as just `email` on the temrinal. Package: @react-email/preview Resolution: Needs More Information More information is needed on this issue labels Dec 19, 2024
@gabrielmfern
Copy link
Collaborator

Everyone go for my fix above, if your case is not the one I mentioned, share a minimal reproduction, and I'll check it out.

@mjacquin
Copy link

Many of the times I saw this error, while having all the packages installed, it was always because of an unwanted .pnp.cjs file at some place higher up from the project. Try looking up from the project, one directory at a time, while looking for a .pnp.cjs if there is one, delete it.

Worked for me !
The .pnp.cjs file was in my home directory.

Thanks @gabrielmfern

@iampapagray
Copy link
Author

@gabrielmfern Sorry about the delayed feedback. I can't find this file you mentioned in my project. I've searched both manually and with IDE and system search but nothing came up.

@gabrielmfern
Copy link
Collaborator

@iampapagray not 100% sure all kinds of system search will find it, do it as I mentioned, and you're probably going to find it. Your IDE is also not going to detect it, since it's most likely in a directory higher up from your project, as I mentioned.

But still, if you're in doubt of whether this is the cause or not, you can just test the same project on another machine. If the SAME error persists, then we can be sure it isn't caused by the .pnp.cjs file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
App: Preview Package: react-email This is the CLI we generally use as just `email` on the temrinal. Resolution: Needs More Information More information is needed on this issue Type: Bug Confirmed bug
Projects
None yet
Development

No branches or pull requests

4 participants