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

Unable to build or preview on Windows with pnpm #225

Closed
ibrahimqasim-abtrace opened this issue Oct 17, 2024 · 11 comments
Closed

Unable to build or preview on Windows with pnpm #225

ibrahimqasim-abtrace opened this issue Oct 17, 2024 · 11 comments

Comments

@ibrahimqasim-abtrace
Copy link

ibrahimqasim-abtrace commented Oct 17, 2024

  • Component or Package Name: jsx-email
  • Component or Package Version: 2.0.11
  • @jsxp-email/cli Version?: 2.0.11
  • Operating System (or Browser): Windows
  • Node Version: 20.11.0
  • Link to reproduction (⚠️ read below): see below (no reproduction since this seems Windows only)

Expected Behavior

On Windows, using pnpm add jsx-email and then pnpm exec email should work.

Actual Behavior

I get the following:

Error: Cannot find package 'C:\Users\...\node_modules\.pnpm\[email protected]_@[email protected]_@[email protected]_@jsx-email+plugi_aa36goewgvdrg3yibk263feoom\node_modules\md-to-react-email\package.json' imported from C:\Users\...\node_modules\.pnpm\[email protected]_@[email protected]_@[email protected]_@jsx-email+plugi_aa36goewgvdrg3yibk263feoom\node_modules\jsx-email\dist\esm\components\markdown.js
Did you mean to import [email protected][email protected]/node_modules/md-to-react-email/dist/index.js?
    at legacyMainResolve (node:internal/modules/esm/resolve:214:26)
    at packageResolve (node:internal/modules/esm/resolve:840:14)
    at moduleResolve (node:internal/modules/esm/resolve:910:20)
    at defaultResolve (node:internal/modules/esm/resolve:1130:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
    at link (node:internal/modules/esm/module_job:84:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Additional Information

I've tried to clear the pnpm store, clear cache, reinstall, etc. Still the same issue.

I tried running the same command on WSL and it works fine.

@shellscape
Copy link
Owner

Have you tried removing node_modules and running pnpm i again?

@ibrahimqasim-abtrace
Copy link
Author

Have you tried removing node_modules and running pnpm i again?

I have.

I'm just trying to do a complete fresh install now. I asked some colleagues to try the same thing and it worked for them, so potentially something is broken with my setup. Will update if it fixes anything.

@ibrahimqasim-abtrace
Copy link
Author

Issue remains. Have reinstalled pnpm. On the latest version 9.12.2. Have made sure long paths on Windows are enabled. Etc.

@shellscape
Copy link
Owner

Thanks for trying all of that. I fired up a VM on my end and couldn't reproduce it. I'm going to add some new CLI tests for Ubuntu and Windows to the CI/CD workflows, but without being able to reproduce it, it's going to be very difficult to find a resolution.

There's a few other things you can try to self-traige:

  • using npx email
  • using node (path to bin)

This does look like a dependency resolution issue, so you might also try using a different node-modules linker strategy https://pnpm.io/npmrc#hoist

shamefully-hoist has been known to resolve phantom issues with pnpm in the past.

@ibrahimqasim-abtrace
Copy link
Author

Thanks for trying. Here are some other things I tried and the results, in case something helps.

Using it without install did not work.

> pnpm dlx email
 ERR_PNPM_DLX_NO_BIN  No binaries found in email

Adding shamefully-hoist did not work.

Using npm install then npx worked.

@shellscape
Copy link
Owner

That's really interesting. It's definitely a pnpm issue. The ERR_PNPM_DLX_NO_BIN is particularly interesting since the package.json clearly has a bin defined. I think this would be worthwhile to report to pnpm as an issue as well, linking back to this one.

If you're working from a branch or a fork, it may be worth running git checkout origin/main -- pnpm-lock.yaml and then running pnpm i again to see if that resolves it. I've seen a local branch lockfile get corrupted a few times in the past.

Also worth trying is the create command in a separate directory, outside of the repository that isn't working. https://jsx.email/docs/quick-start#new-projects. If that works out of the box in the new directory, the next step would be to remove node_modules there, and then use pnpm to reinstall node_modules in the same directory. If pnpm fails there, then that points to a wider system issue.

Next step, if none of the above work, I'd recommend is completely nuking your local store (which I've also had to do a few times). First thing I do is pnpm store prune (https://pnpm.io/cli/store#prune) and then using pnpm store path permanently delete the pnpm store. It'll be recreated on the next pnpm i.

I could also take a look at your lockfile to see if there's anything which stands out there, if you'd like to put that into a gist (https://gist.github.com)

@ibrahimqasim-abtrace
Copy link
Author

Dont worry. It was Windows all along 😭 I was demonstrating the issue to someone and it worked (observer effect...). After a bit more playing around I tried to make sure it wasn't the path issue, and lo and behold, at 261 characters Node broke. The specific path that broke was: C:\Users\...\basedir\node_modules\.pnpm\[email protected]_@[email protected][email protected]__@[email protected]_@j_ji2fvnlvayidcqpmi7tlnbwdsi\node_modules\source-map-support\source-map-support.js

I then found the solution: nodejs/node#50753 (comment)

Upgrading to Node 22.7 fixed the issue.

Massively massively frustrating issue... but thank you very much for the help.

@shellscape
Copy link
Owner

No problem! Very happy you were able to find the issue. I'll make a mental note about the Node version as well. Really appreciate your time triaging and sharing what the issue ended up being.

@ibrahimqasim-abtrace
Copy link
Author

Actually, that solution seemed to not work. I tried with a longer base path and have started getting the same issues as before. This is even with shamefully-hoist = true.

@shellscape
Copy link
Owner

Definitely open an issue with pnpm about this. I'm not sure there's anything actionable that I can do with this project. Is using WSL an option? My guess is that you'll run into this again with any long dependency paths

@ibrahimqasim-abtrace
Copy link
Author

This is definitely a Node / pnpm issue. Just wanted to inform you. I'll open an issue with them in the morning. Unfortunately, WSL is a last resort, but I tested the same thing there and it worked.

Thank you again for being so helpful and looking into this!

For posterity, I was able to get my specific situation to start working by setting node-linker = hoisted in .npmrc.

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