resend / react-email

💌 Build and send emails using React
https://react.email
MIT License
12.67k stars 583 forks source link

Files go missing. ENOENT: no such file or directory .react-email/package.json #697

Closed maakle closed 2 months ago

maakle commented 1 year ago

Describe the Bug

I am unable to start the dev mode and receive the following error:

makle nextjs-app % yarn email-dev
yarn run v1.22.19
warning ../../../package.json: No license field
$ email dev
✔ Emails preview generated
[Error: ENOENT: no such file or directory, open '/Users/makle/Developer/paysome/nextjs-app/.react-email/package.json'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/Users/makle/Developer/paysome/nextjs-app/.react-email/package.json'
}

Inside the .react-email folder it seems the file went missing with everything else. the src folder is empty. Also reinstalling my dependencies on root level doesn't bring them back. Also removing react-email from my package.json and adding it back, doesn't bring it back. Is there a way how I can regenerate them?

Screenshot 2023-06-02 at 11 02 58

I suspect it might have something to do with my .gitignore file. I added the the /.react-email/ folder to it, since the repo otherwise is getting too big.

Did anyone experience the same or have an idea how to solve this?

Which package is affected (leave empty if unsure)

react-email

Link to the code that reproduces this issue

https://github.com/resendlabs/react-email/blob/main/package.json

To Reproduce

Try adding react-email to an existing project. Add /.react-email/ to your ignore. Commit things to git. Try reinstalling.

Expected Behavior

Dev mode to start

What's your node version? (if relevant)

16.16.0

CBYMachumbe commented 11 months ago

Any work around for this?

maakle commented 11 months ago

@CBYMachumbe So my workaround for this is having a separate project which I created with the CLI like here. I designed the emails there and then simply copied the files over to my actual project and used it there.

Not great but I was able to continue. I would highly appreciate if this problem would be addressed / fixed though!

paalaleks commented 11 months ago

Will there be a solution here soon?

nicholasess commented 11 months ago

@maakle I used the react-email as packages on my monorepo with pnpm and it works fine. my server called the packages and use functions that send email with react-email templates

vasyaqwe commented 11 months ago

nothing helped, including installing canary. I moved everything from the client dir to root. That fixed it. Weird

maakle commented 11 months ago

nothing helped, including installing canary. I moved everything from the client dir to root. That fixed it. Weird

You had a mono repo with backend & frontend or what do you mean with moving client dir to root?

vasyaqwe commented 11 months ago

Not root, my bad, I meant to say .react-email. I just set it up automatically with npx create-email@latest, and cut all the contents from .react-email/client to .react-email, replacing all the files that were already there.

nothing helped, including installing canary. I moved everything from the client dir to root. That fixed it. Weird

You had a mono repo with backend & frontend or what do you mean with moving client dir to root?

EduardoFazolo commented 11 months ago

I cannot reproduce this bug, can someone confirm it's still happening? These are the steps I followed to attempt to replicate:

  1. Inside my project's folder I run npm install react-email@latest
  2. Create the ./emails folder with the email components
  3. Run npx email dev, this will create the /.react-email/ folder
  4. Add ./react-email/ to .gitignore
  5. Commit and push changes to github, then go to another directory and clone the repository.
  6. Run npm install
  7. Run npx email dev

The .react-email/src/... directory was created as expected and everything ran well.

maakle commented 11 months ago

Hey @EduardoFazolo I just created a sample project but can confirm, that I couldn't replicate the issue with the latest version. See https://github.com/maakle/react-email-bug that it worked!

That being said, I also just went back to my main project and did the following:

  1. Removed react-email from package.json and ran yarn to remove the package
  2. Deleted .react-email folder
  3. Added the package back with yarn add react-email@latest -> Upgraded to 1.9.4, i was previously on 1.9.3

And that seem to have done the trick. It regenerated the react-email files and I was able to run email dev again.

So I don't know what happened but it works again. Seems like magic or you did something in the minor upgrade from 1.9.3 to 1.9.4

Can anyone else confirm that this also worked for them who experienced the same problem? Then I can close the issue.

laertepires commented 11 months ago

I had this same problem.

As an alternative solution I created the project using the manual way as recommended in the documentation and it didn't happen anymore

https://react.email/docs/getting-started/manual-setup#1-create-directory

theDanielJLewis commented 11 months ago

This fails for me now, too. Both yarn and npm, @latest and 1.9.3.

But it worked before I started messing with things to figure out how to properly install addons (since the yarn method warns me to use -W).

I could restore from my Git repo, but that doesn't include node_modules or .react-email. So whatever is causing this new problem must be within one of those folders. (Great work, Sherlock, I know.)

kierangillen commented 5 months ago

For me deleting .react-email folder and running email dev again fixed the issue.

gabrielmfern commented 2 months ago

Closing this as we don't include a .react-email directory at all anymore as of react-email@2.0.0. You all can upgrade to our latest — react-email@2.1.0 — and things should be much smoother on all aspects.

The upgrade shouldn't be very hard, but if you do find any issues, you can mention me, or look into the guide at https://resend.com/blog/react-email-2#upgrade-instructions for upgrade instructions.