react-email: renderToReadableStream not found in react-dom/server
Describe the Bug
We are testing out react-email for use in our project, but getting this error when trying to deploying a test template:
yarn start
yarn run v1.22.19
$ serverless offline --httpPort 4051 --stage local --host 0.0.0.0
serverless-offline-ssm checking serverless version 3.33.0.
✖ in ../node_modules/@react-email/components/node_modules/@react-email/render/dist/index.mjs 31:23-45
export 'renderToReadableStream' (imported as 'renderToReadableStream') was not found in 'react-dom/server' (possible exports: renderToNodeStream, renderToPipeableStream, renderToStaticMarkup, renderToStaticNodeStream, renderToString, version)
Template code:
import React from 'react'
import {
Body,
Head,
Heading,
Container,
Html,
Text,
} from '@react-email/components'
interface AccessRequestParams {
testName: string
}
export const accessRequestExpiryTemplate = ({
testName,
}: AccessRequestParams) => (
<Html>
<Head />
<Body>
<Container>
<Heading>TEST</Heading>
<Text>Here are the details of the request:</Text>
<Text>{testName}</Text>
</Container>
</Body>
</Html>
)
export default accessRequestExpiryTemplate
Package.json versions
"dependencies": {
"@react-email/components": "^0.0.7",
"react-email": "^1.9.4",
"react": "18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.11.2",
"react-tooltip": "4.2.21",
}
Which package is affected (leave empty if unsure)
Link to the code that reproduces this issue
n/a
To Reproduce
Deploy with the listed package versions - We’re using serverless: ‘“start”: “serverless offline --httpPort 4051 --stage local --host 0.0.0.0”’
Expected Behavior
The code should compile cleanly without this import error
What’s your node version? (if relevant)
18.13.0
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 14
- Comments: 63 (7 by maintainers)
Commits related to this issue
- Fix #868 by importing function correctly. — committed to michael-dickinson-sainsburys/react-email by michael-dickinson-sainsburys 10 months ago
I’ve been using this happily with Next.js 13.5.6 but it fails immediately on upgrade to Next.js 14.0.0.
Can confirm this completely breaks on Next 14.0.0
We’re currently working on a fix for that. Will keep you all posted.
Confirming that react email worked fine until upgrading to next 14.
For me this issue pops up with the latest Next.js release v13.5.6, which bumped the version of React it uses
Yup this breaks on upgrade to Next 14 🙃
@catalinpit I was able to resolve the issue as well. Thank you. Below is the method I applied:
.react-emaildirectory and then delete thepackage-lock.jsonandyarn.lockfiles.@react-email/renderinpackage.jsonfrom"0.0.7"to"0.0.9".yarnIf anyone is looking for a temporary NextJS 14 fix (using @Moicky’s solution)
in next.config.js add these imports:
& add this webpack configuration somewhere in the file:
Finally, create a new file
renderEmailFix.jsin the root folder with this code:My experience with https://github.com/shellscape/jsx-email has been good so far. It’s easier to set up the preview server and bugs get fixed quickly if you offer a reproduction.
Also unable to get working with NextJS 14
We just released a new canary version
@react-email/render@0.0.9-canary.2.here’s an example on Next.js 14 app router edge
This actually worked, thanks! Delete package-lock and node_modules, npm i, and it’s working.
Okay, the solution was simpler than expected.
Even though I updated package.json with the appropriate version, the package-lock.json contained the older versions, and the app somehow picked those (something something about the node module resolution algorithm).
To fix this, I added the line “
@react-email/render": "0.0.9” both under the “dependencies” and “overrides” in the root package.json. It now forces all references to that package to use v0.0.9Many thanks to @lxunos for the fix/lesson. 🙏
Working for me…appreciate the fast work
So I have updated to
"resend": "^2.0.0-canary.0"and this issue is resolved.Issue => https://github.com/resendlabs/resend-node/issues/244
@bukinoshita also still getting build time error. Tried
@react-email/render0.0.9-canary.0and0.0.9-canary.1with"@react-email/components": "0.0.9"and"react-email": "1.9.5",.@bukinoshita I still get it with
The new release doesn’t work because in
package.jsonappearsworkspace:*https://www.npmjs.com/package/@react-email/components?activeTab=code
Following, exited to get rid of experimental in next.config.js I updated to 14 and now get ./node_modules/@react-email/render/dist/index.mjs Attempted import error: ‘renderToReadableStream’ is not exported from ‘react-dom/server’ (imported as ‘renderToReadableStream’).
Hey Guys, Those who use the Resend library, update to V2.0.0, it works in Next14. https://www.npmjs.com/package/resend
I also moved to jsx-email. Way better and is not breaking. Migration took 10 minutes.
As @bukinoshita mentioned, the fix is in
@react-email/render@0.0.9We’ll just need to upgrade your local
@react-email/renderpackage from “0.0.7” to “0.0.9”../react-starter-email/package.json, pin the @react-email/render version to 0.0.9 using resolutions and also bump the dep versions for good measure:npm/yarn/pnpm installto apply the change.Thanks @shellscape , I moved over to jsx-emails and it worked straight out of the box. And migration (for my very small use case) was painless too
The patch file I posted yesterday is also working fine for me.
On Fri, Oct 27, 2023 at 7:43 AM themendelson @.***> wrote:
So now there are no patch/fix solution for react-email with Next 14 ?
Thank you so much @shellscape! Here is a patch file that implements this for
@react-email/renderIt works for me, Thank you.
It worked for me
my nextjs version: “next”: “14.0.4”,
+1 for migrating to
jsx-email. Painless and worked out of the box in our nx monorepo.Can you try using the canary version of render to see if this is still happening?
Maybe this helps someone:
I needed a quick fix since my webpack kept crashing due to this function not being available in my NodeJS environment.
I used
NormalModuleReplacementPluginto provide a fake implementation since this function is not used in my app:No luck with any of the above packages. What magic are you all using? 😂 Also on next14, with overrides and all.
render
If you’re still having issues with
renderToReadableStreamon@react-email/render, you should upgrade the@react-email/rendertov0.0.9(latest).Eg:
components
If you’re still having issues with
renderToReadableStreamon@react-email/components, you should upgrade the@react-email/componentstov0.0.11(latest).Eg:
resend
If you’re still having issues with
renderToReadableStreamonresend, you should upgrade theresendtov2.0.0(latest).Eg:
Still having issues after upgrading
renderorcomponents, please provide a code example and your setup (a reproducible repository works better)resend, please follow up in theresend-noderepositoryNone of the options above worked for me.
I might have found a solution though: installing components separately, rather than using
@react-email/components. So I have them in mypackage.jsonlike this now:Everything works great and builds with no errors, even with the latest version of
resend(2.0.0). I am using Next 14.0.1. Hope that helps someone! I spent way too much time trying to fix react-email and resend related errors lately@alerimoficial We have a Resend version that upgrades the react-email version once the issue is fully fixed
I tried to upgrade to 0.0.9-canary.1 but looks like the resend still depends on 0.0.7 @react-email/render version.
I’m wondering what’s your setup, if one can confirm how are you using? I’m testing this way in next.js 14
@subvertallchris no prob. fwiw we’ve completely moved away from using react for rendering, which makes it fully compatible with edge and all fe frameworks. using react for rendering was a big footgun
Here’s what the fix for this looks like https://github.com/shellscape/jsx-email/commit/2eeebfcba9f8c900d0a137ebd8e9086c26eb4054