Skip to content

email build fails on Vercel — installDependencies does not install package #2992

@maximwas

Description

@maximwas

What versions are you using? (if relevant)

@react-email/components@x.y.z, react-email@x.y.z, etc.

Describe the Bug

Describe the bug

When deploying to Vercel using the official deployment guide, email build fails with:

✔ Successfully prepared `.react-email` for `next build`
sh: line 1: cross-env: command not found
Error: `npm run build` failed.

Note that .react-email is successfully prepared but then npm run build inside it fails because cross-env (and other packages) are not installed.
Root cause
In build.ts, installDependencies is called to install packages inside .react-email:

if (!isInReactEmailMonorepo) {
  await installDependencies({ cwd: builtPreviewAppPath })
}

On Vercel isInReactEmailMonorepo = false so installDependencies should run — and based on logs it does start — but Vercel cancels or ignores the nested npm install inside .react-email subfolder. As a result .react-email/node_modules is never created and packages like cross-env, next, etc. are missing when npm run build runs.

Steps to reproduce

  1. Create a standard react-email-starter project
  2. Follow the official Vercel deployment guide
  3. Set Framework Preset → Next.js, Output Directory → .react-email/.next
  4. Push to Vercel — build fails

Environment

react-email: 5.2.9
@react-email/preview-server: 5.2.9
Node: 20.x (Vercel default)

Expected Behavior

When following the official Vercel deployment guide, running email build on Vercel
should automatically install all required dependencies inside .react-email and
successfully complete next build without any manual workarounds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions