resend / react-email

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

Build error due to dependency installation #1432

Closed junminahn closed 2 weeks ago

junminahn commented 3 weeks ago

Describe the Bug

When executing the command email build, I encountered the following error:

   ⠼ Installing dependencies on `.react-email`Error: Unable to install the dependencies and it exited with code: 1
    at /myproject/node_modules/react-email/cli/index.js:2083:36
    at /myproject/node_modules/shelljs/src/exec.js:145:9
    at ChildProcess.exithandler (node:child_process:430:5)
    at ChildProcess.emit (node:events:518:28)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5)

Upon investigating further by running npm install in the .react-email directory, I found a more detailed error message:

/.react-email$ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: react-email@2.1.1
npm ERR! Found: react@18.3.0
npm ERR! node_modules/react
npm ERR!   react@"^18.2.0" from the root project
npm ERR!   peer react@"^16.8 || ^17.0 || ^18.0" from @radix-ui/react-collapsible@1.0.3
npm ERR!   node_modules/@radix-ui/react-collapsible
npm ERR!     @radix-ui/react-collapsible@"1.0.3" from the root project
npm ERR!   5 more (react-dom, @radix-ui/react-popover, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! @react-email/components@"0.0.16" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: react@18.2.0
npm ERR! node_modules/react
npm ERR!   peer react@"18.2.0" from @react-email/components@0.0.16
npm ERR!   node_modules/@react-email/components
npm ERR!     @react-email/components@"0.0.16" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

This issue appears to stem from a conflict with the recently published version of react: https://www.npmjs.com/package/react

Which package is affected (leave empty if unsure)

react-email

Link to the code that reproduces this issue

https://www.npmjs.com/package/react

To Reproduce

Expected Behavior

it builds the email templates without build errors.

What's your node version? (if relevant)

No response

gabrielmfern commented 3 weeks ago

It seems like we are having this same issue when building our demo application. Thank you for opening this issue!

MatiasVerdier commented 3 weeks ago

Same error with our project

aaronmw commented 3 weeks ago

Same here. react@18.3.0 might fix? Can't build our app anymore either.

thianphat commented 3 weeks ago

likewise!

mickasmt commented 3 weeks ago

Same for me. This worked before react@18.3 was released. It seems react-email needs an update. @aaronmw were you able to test?

MatiasVerdier commented 3 weeks ago

A temporary solution is patching the dependency to the exact react version (18.2.0). You can use pnpm patch or patch-package to accomplish this

aaronmw commented 3 weeks ago

It's actually @react-email/components that won't install. I can install react-email with React 18.2.0 just fine, but the components package fails. I can't use patch-package on a package that won't even install, I don't think? @MatiasVerdier ?

MatiasVerdier commented 3 weeks ago

@aaronmw It worked for me, @react-email/components is already using the exact version 18.2.0 instead of ^18.2.0

https://github.com/resend/react-email/blob/main/packages/components/package.json#L66

The patch will allow you to install. I've used pnpm patch as you can see here image

aaronmw commented 3 weeks ago

Hmm. Maybe we have different issues. My project is using ^18.2.0 and I can install react-email just fine. In fact, it installs on ^18.3.0 as well. It's only @react-email/components that won't install on either version now. One conflicts with some group of packages, while another causes conflicts on another group of packages 🤦

aaronmw commented 3 weeks ago

Oops, I see what you did. Patching react-email fixes @react-email/components — sorry, it's early 😆 Works now! 🎉 🙏

MatiasVerdier commented 3 weeks ago

@aaronmw but that's the issue, having ^18.2.0 means the project will install version 18.3.0 and that doesn't meet the criteria for @react-email/components and that's why it fails. once you change the dependency in react-email to be same it will work just fine

gabrielmfern commented 3 weeks ago

We will be fixing this in a new version for @react-email/components today, and I will let you know once we do.

Update: we will try releasing on Monday

aaronmw commented 3 weeks ago

@gabrielmfern Thank you 🙏 Seems my project doesn't build on 18.2.0 since some OTHER packages apparently insist on 18.3.0 already.

mickasmt commented 3 weeks ago

Currently, its works for me without pnpm patch. Thanks all!!

Meags27 commented 3 weeks ago

Same issue here, a bunch of my vitest tests won't work because of this dependency issue with react and react-email

praveentcom commented 3 weeks ago

Looks like new version is not released yet. @gabrielmfern any ETA on this?

gabrielmfern commented 3 weeks ago

@praveentcom We weren't able to do it yesterday, will try Monday.

anthonyhagi commented 2 weeks ago

Any updates on when this will be released?

gabrielmfern commented 2 weeks ago

We just released a new version for all the packages that has a proper version for react as their peer dependencies. It is now ^18.2.0, so it should allow you to use either 18.2.0 or 18.3.0, and also with any patch version for them.

You should upgrade react-email and @react-email/components as well as any other individual components you have installed to the latest. If anyone experiences this issue or something like this, please let me know and I'll reopen the issue.

See https://github.com/resend/react-email/releases/tag/react-email%402.1.2

praveentcom commented 2 weeks ago

Thanks @gabrielmfern!