react-email: email command fails within pnpm workspace
Describe the Bug
Following the manual setup inside a pnpm monorepo with a pnpm-workspace.yaml in the root, the email command fails like this:
✔ Emails preview generated
⠋ Installing dependencies...
Scope: all 13 workspace projects
✔ Dependencies installed
> react-email-client@0.0.14 dev /Users/.../libs/email/.react-email
> next dev "--" "-p" "8790"
sh: next: command not found
ELIFECYCLE Command failed.
WARN Local package.json exists, but node_modules missing, did you mean to install?
Turns out a script was running a pnpm install command, but since it’s in the workspace, it simply installed the other packages, but skipped the new one since it doesn’t match a pattern.
I solved this by adding [package-path]/.react-email in pnpm-workspace.yaml. Not sure the best general solution. Posting here mainly to help anyone else hitting the same issue.
Which package is affected (leave empty if unsure)
react-email
Link to the code that reproduces this issue
https://react.email/docs/getting-started/manual-setup
To Reproduce
- Create a pnpm workspace
- Follow https://react.email/docs/getting-started/manual-setup within a package
Expected Behavior
The email command would succeed, or at least provide a clearer error.
What’s your node version? (if relevant)
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 29
- Comments: 18 (1 by maintainers)
@bukinoshita If I understand correctly, the current model of the preview server is:
This seems overly complex. If someone is using the
react-emailpackage then they will, with absolute certainty, need to install the dependencies insideclientat some point in life. Why are those dependencies only defined there, rather than have them exist as dependencies ofreact-emailitself? Which brings me to my next question - Why isclientdownloaded extracted and ran as a separate project? The next server could be created from within the cli tool, which would fix this issueI’d be glad to work on a PR for the aforementioned change if it’s relevant
pretty easy workaround is to add the .react-email folder to your
pnpm-workspaces.yamledit: to add more explanation, pnpm workspaces don’t look for hidden directories that start with
., which is why you need to manually add it in thepnpm-workspaces.yamlfile. there technically is no bug or issue here, it’s just how pnpm worksCan we configure the client to work with
pnpmby default?Also just ran into this
I’m using this patch as a workaround to use this package in a
pnpmproject. You may use it with the patch feature inpnpm.Alright fast followup: If you run
npm installwithin the.react-emaildirectory (even though we’re using pnpm), it’ll install packages intonode_modulesand the dev server will run.I maintain that this is a pretty bad way to ship a dev server, but that’s a workaround that requires some manual steps. If you’re using a build tool like moon, this step can probably be automated.
I am also having this issue when using it though pnpm workspaces. For now the only work around I use is to go into the .react-email folder and do a
yarn install. Then theemail devcommand works pretty well after this.