ERR_REQUIRE_ESM when running pnpm build for Vite + React project
I just migrated from code-based to file-based routing.
at Module.<anonymous> (/Users/me/Desktop/project/Frontend/node_modules/.pnpm/@tanstack+router-generator@1.86.0/node_modules/@tanstack/router-generator/dist/cjs/filesystem/virtual/getRouteNodes.cjs:3:1) { code: 'ERR_REQUIRE_ESM'
at Module.<anonymous> (/Users/me/Desktop/project/Frontend/node_modules/.pnpm/@tanstack+router-generator@1.86.0/node_modules/@tanstack/router-generator/dist/cjs/filesystem/virtual/getRouteNodes.cjs:3:1) { code: 'ERR_REQUIRE_ESM'
16 Replies
deep-jade•10mo ago
please provide a minimal complete example , e.g. by forking one of the existing examples on stackblitz
stormy-goldOP•10mo ago
Oh it seems like its because my build script was this
Removing
tsr generate
fixes this issuedeep-jade•10mo ago
it should still work
with tsr
stormy-goldOP•10mo ago
Seems like it does not - will see if i can reproduce
xenial-black•10mo ago
I am also getting this issue with the
tsr generate
command. I am running all the latest @tanstack
packages:
Full error is:
deep-jade•10mo ago
can you share a reproducer?
xenial-black•10mo ago
This is the project I've just started that I am running into this issue with:
https://github.com/beefchimi/earwurm-react-demo
Sorry, it isn't as minimal of a reproduction as you may want, but it should still hopefully be helpful.
GitHub
GitHub - beefchimi/earwurm-react-demo: Exploration of using Earwurm...
Exploration of using Earwurm in React. Contribute to beefchimi/earwurm-react-demo development by creating an account on GitHub.
deep-jade•10mo ago
do you even use virtual file routes?
xenial-black•10mo ago
nope
There are no imports from
virtual-file-routes
or calls to rootRoute
.
only calls to createRootRoute
I think I finally got that command to run by downgrading all of the tanstack dependencies... not sure exactly what the last working version is though. I'm generally in the 1.85.0
rangedeep-jade•10mo ago
if you can narrow it down it makes it easier for me to spot the issue
xenial-black•10mo ago
Here is exactly what I downgraded that led to a working router generation:
https://github.com/beefchimi/earwurm-react-demo/commit/f01ebce7ff61cc7d22b001d4708bc248eaa40342
I can say that the
@tanstack/router-generator
package is definitely required in order for this to have worked... where as I believe the @tanstack/react-router
documentation doesn't state that this is a requirement.
Neither these pages requires you to install the router-generator
:
- https://tanstack.com/router/latest/docs/framework/react/installation
- https://tanstack.com/router/latest/docs/framework/react/quick-start
I can bring back the error by either:
- Removing the router-generator
package and reinstalling my node modules, or
- Bumping router-generator
to ^1.86.0
deep-jade•10mo ago
ok will look into this later
can you point me to a commit that fails to build?
ah wait I can reproduce
this fails with
npm
but works with pnpm
with npm I get the following file in node_modules/.bin/tsr
:
whereas with pnpm:
can you please create a github issue for this?xenial-black•10mo ago
Yep, one minute
xenial-black•10mo ago
GitHub
[Generator] Failure to generate routes with NPM · Issue #2968 · Tan...
Which project does this relate to? Router Describe the bug See Discord discussion for more context: https://discord.com/channels/719702312431386674/1023930177224462388 It appears that something shi...
xenial-black•10mo ago
@Manuel Schiller thank you for fixing this!
correct-apricot•10mo ago
I'll check it out once it's out. Had this behaviour with pnpm + RsPack + Nx.