react-email: ENOENT Error - no such file or directory, scandir in react-email package
Describe the Bug
Despite following the manual setup from the documentation, I’m unable to start the dev server. The error message I’m receiving is: Error: ENOENT: no such file or directory, scandir 'D:\Projects\react-email-starter\.react-email\emails'
Environment: OS: Windows 11 Node: 18.16.0
I downgraded the react-email package from v1.9.3 back to v1.9.0 and the issue is gone.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 18
- Comments: 34 (4 by maintainers)
Commits related to this issue
- fix (npx): update the react-email version use by the automatic setup closes #677 — committed to resend/react-email by gabrielmfern 8 months ago
- fix (npx): update the react-email version use by the automatic setup closes #677 — committed to resend/react-email by gabrielmfern 8 months ago
- fix (npx): update the react-email version use by the automatic setup closes #677 — committed to resend/react-email by gabrielmfern 8 months ago
- fix (npx): update the react-email version use by the automatic setup closes #677 — committed to resend/react-email by gabrielmfern 8 months ago
- fix (npx): update the react-email version use by the automatic setup closes #677 — committed to resend/react-email by gabrielmfern 8 months ago
Using react-email@1.9.3-canary.0 works for me, thanks for fixing.
Hey guys! I was facing the same issue, and something that helped was downgrading the version of react-email to @1.9.0.
npm i react-email@1.9.0then runnpm run devagainedit: I tested version
@1.9.4and it also worked, so the error is related to version@1.9.3.im using windows 11
Pretty poor first impression… @Julienh is right, upgrade to 1.9.4 and deleting the .react-email folder should get it working.
I’m on Windows 10.
Still happening with
npx create-email@lateston windows 11I have the same issue just after running
npx create-email@latestin an empty directory (Windows 11)The general preview gets fixed after downgrading the version. But when you try to access to the individual preview of the email it shows:
Server Error TypeError: Cannot read properties of null (reading ‘1’)
This error happened while generating the page. Any console logs will be displayed in the terminal window. Source src\app\preview[slug]\page.tsx (36:75) @ Page
34 | encoding: ‘utf-8’, 35 | });
Environment: OS: Windows 11 Node: 18.16.0
How to find this issue:
I used the automatic setup
Solution
Why does this even happen in the first place?
The issue occurs because React-Email has trouble reading the file structure and fails to access files correctly. However, I have identified the problem and implemented the necessary fixes to address this issue.
Steps to Reproduce
.react-emailfolder in your file structure..react-email/src/utils/get-email.ts.src/app/preview/[slug]/page.tsxto:
to:
After making these changes, the issue should be resolved.
Please note that commenting out the code block in step 9 may result in an error where the Preview component in your JSX cannot find “reactMarkup”. To fix this, you can pass exportTemplateFile to the component.
it still happen on windows
I switched all my emails from
react-emailtojsx-emailin around an hour and I’m having FAR less trouble, no issues stopping/starting and no need to be deleting folders and reinstalling all the timeThank you. Finally got it worked. Follow the doc from https://react.email/docs/getting-started/automatic-setup never works.
I’m very disappointed with this package because I can’t make it preview work with any version. I’m on
macOs Ventura 13.5withNextJs 13.4.16using theappfolder inside thesrcfolder.About to use canary, this is also happening for me on main branch
Can we confirm this only happens on Windows?
For anybody that is still having issues: the
npx create-email@latestcommand installs an old version of the react-email that have issues with windows.If you run
devwith it, it will create the folder and files at.react-emailand break as everybody said before.When you upgrade to 1.9.4 or greater, make sure to DELETE the folder. In my case, I deleted the folder content and not the folder itself because some process was using it. If that is your case, reboot and delete it before running the
yarn devcommand and it should work.I have the same problem for a long time and get mad because there is no solution. not happy. I switch to server https://jsx.email/docs/quick-start#email-previews and use the same emails. Why doesn’t the react-email project matter for fixes?
v1.9.4in package.json, deletingnode_modulesandreact_emailand running install again worked for me.I’m facing the same issue with
v1.9.5. I’m running a NextJS app with JavaScript on Windows 10.The problem for me was that the
./emailsfolder did not get copied under.react-emailfolder even though the path was fine. But this occurred only with JavaScript. (Even after copying it manually there, further issues got triggered.)I came around this problem by writing my email templates in TypeScript instead of JavaScript.
I upgraded to the 1.9.4 and had the same error.
I deleted the .react-email and node_modules folder and tried again, it is now working. Thank you.
In my case I’m using a MacBook
I’ve been using the library in a MAC, and everything works fine. I was until I tried to run the server/use the library on OS: Windows 11/ Windows 10 that the original issue posted here shows.