Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick start with a new project fails #283

Open
TomOne opened this issue Jan 17, 2025 · 4 comments
Open

Quick start with a new project fails #283

TomOne opened this issue Jan 17, 2025 · 4 comments

Comments

@TomOne
Copy link

TomOne commented Jan 17, 2025

  • Component or Package Name: create-jsx-email
  • Component or Package Version: 2.1.0
  • @jsxp-email/cli Version?: none
  • Operating System (or Browser): Ubuntu 24.04
  • Node Version: 22.13.0
  • Link to reproduction (⚠️ read below): unable to provide one, see below

An error occurs when I try to follow these instructions: https://jsx.email/docs/quick-start#new-projects

Steps to reproduce

  1. npm create jsx-email
  2. cd email-project && npm install
  3. npm run dev

Expected Behavior

No errors when running npm run dev.

Actual Behavior

$ npm run dev

> [email protected] dev
> email preview ./templates

[12:00:00]  info  Found 1 file:
[12:00:00]  info     /tmp/email-project/templates/email.tsx 

[12:00:00]  info  Starting build...
Error: Cannot find module '/jsx-email/build/email-PLODGWOF.js' imported from /tmp/email-project/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@jsx-email+plug_hdwmguib65h4hbdsg3y6z7yvjm/node_modules/jsx-email/dist/esm/cli/commands/build.mjs
    at finalizeResolution (node:internal/modules/esm/resolve:275:11)
    at moduleResolve (node:internal/modules/esm/resolve:932:10)
    at defaultResolve (node:internal/modules/esm/resolve:1056:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:654:12)
    at ModuleLoader.#cachedDefaultResolve (node:internal/modules/esm/loader:603:25)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:586:38)
    at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:242:38)
    at onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:546:36)
    at TracingChannel.tracePromise (node:diagnostics_channel:344:14)
    at ModuleLoader.import (node:internal/modules/esm/loader:545:21)

The code appears to import a non-existing file. The /build directory is not created.

Additional Information

The StackBlitz reproduction template doesn’t seem work either. Running it fails with the following error:

> [email protected] dev
> email ./templates

jsh: spawn email ENOENT

Therefore I’m unable to provide a link to reproduce the error.

@shellscape
Copy link
Owner

We have a set of smoke tests which uses create-jsx-email to setup the tests, so we have a lot of confidence that it's working correctly. The issue you're running into probably lies elsewhere. It's unfortunate that Stackblitz isn't being maintained anymore, and has issues with standard bash compatibility (which is why it's throwing that error). But the issue template does outline that you can spin up a repository to demonstrate the issue.

This is one of those that without a reproduction, we're not going to be able to help, because what you're seeing is drastically different from what we're seeing.

@TomOne
Copy link
Author

TomOne commented Jan 20, 2025

Thank you for your elaborate answer. I’m sorry I just created this issue without providing a reproducible test case at first. Now I finally managed to consistently reproduce the error by running it inside Docker:

# `yes ""` sends Enter key presses to `npm create jsx-email` to automatically select the defaults.
docker run --rm node:22-slim sh -c 'cd /tmp && yes "" | npm create jsx-email && cd /tmp/email-project && npm install && npm run build'

The final npm run build command throws the same error as above: Cannot find module '/jsx-email/build/email-….

Interestingly, npm run build succeeds without errors when running the same command, but replacing /tmp with a different directory, e.g. /app:

docker run --rm node:22-slim sh -c 'mkdir /app && cd /app && yes "" | npm create jsx-email && cd /app/email-project && npm install && npm run build'

This should be consistently reproducible on any machine with Docker installed. Would you like me to create a GitHub Action or something similar to be able to provide a reproduction link?

Apparently the path to the module is not constructed correctly when running it inside the /tmp directory: /jsx-email/build…, but it should be /tmp/jsx-email/build….

I also got the same error when running npm create jsx-email && … npm run dev in Windows inside the %HOMEPATH%\Downloads directory. I noticed that the smoke tests on Windows have all failed: https://github.com/shellscape/jsx-email/actions/workflows/test-windows.yml. Unfortunately the test logs are no longer available, so I’m not sure if they failed because of this error or because of a different one.

P.S.: Thank you for this project. Being able to create emails with React is great!

@shellscape
Copy link
Owner

OK thanks for doing that deep dive. jsx-email uses the system temp directory to do a lot of file writes and reads. That's not likely to change because that's the standard for that kind of thing. This is likely a problem with how we're resolving the temp paths once they've been constructed. For now the guidance should be not to run this in a system temp directory, but we can take a look at that directory building at some point. (As always if you find the culprit sooner, please let us know and we'll get a fix in for you, or merge a PR for you)

As for the windows smoke tests - that isn't something that's actually in the repo. If you go to main branch and the .github directory, you won't find that there. Those runs are from a user attempting to contribute a Windows version of the Smoke Test workflow. If you could help triage what the issues are on Windows in that %HOMEPATH% scenario, we'd be happy to implement some fixes.

@shellscape
Copy link
Owner

I'll be seeing if there's anything we can do around this, this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants