router icon indicating copy to clipboard operation
router copied to clipboard

start: The requested module '@tanstack/router-generator' does not provide an export named 'CONSTANTS'

Open erik-kroon opened this issue 1 year ago • 15 comments

Which project does this relate to?

Start

Describe the bug

i was updating a different library, ran the following command: $ rm -rf bun.lock && rm -rf node_modules && rm -rf apps/*/node_modules && bun i and afterwards my dev server won't start. at first it was something about @tanstack/react-start/config not exporting defineConfig, switched to @tanstack/react-start-config and now this err

$ vinxi dev --port=3001 vinxi v0.5.7 file:///Users/erik/autoseo/node_modules/@tanstack/react-start-config/dist/esm/vinxi-file-router.js:2 import { CONSTANTS as GENERATOR_CONSTANTS, startAPIRouteSegmentsFromTSRFilePath, } from '@tanstack/router-generator'; ^^^^^^^^^ SyntaxError: The requested module '@tanstack/router-generator' does not provide an export named 'CONSTANTS' at ModuleJob._instantiate (node:internal/modules/esm/module_job:134:21) at async ModuleJob.run (node:internal/modules/esm/module_job:217:5) at async ModuleLoader.import (node:internal/modules/esm/loader:316:24) at async loadFile (file:///Users/erik/autoseo/node_modules/vinxi/lib/load-app.js:83:25) at async loadApp (file:///Users/erik/autoseo/node_modules/vinxi/lib/load-app.js:137:19) at async Object.run (file:///Users/erik/autoseo/node_modules/vinxi/bin/cli.mjs:76:17) at async runCommand (file:///Users/erik/autoseo/node_modules/citty/dist/index.mjs:316:16) at async runCommand (file:///Users/erik/autoseo/node_modules/citty/dist/index.mjs:307:11) at async runMain (file:///Users/erik/autoseo/node_modules/citty/dist/index.mjs:445:7)

ERROR Cannot read properties of undefined (reading 'config') 12:02:19 PM

at Object.run (/Users/erik/autoseo/node_modules/vinxi/bin/cli.mjs:79:9)
at async runCommand (/Users/erik/autoseo/node_modules/citty/dist/index.mjs:316:16)
at async runCommand (/Users/erik/autoseo/node_modules/citty/dist/index.mjs:307:11)
at async runMain (/Users/erik/autoseo/node_modules/citty/dist/index.mjs:445:7)

ERROR Cannot read properties of undefined (reading 'config') 12:02:19 PM

error: script "dev" exited with code 1

Your Example Website or App

do not know how to reproduce unfortunately

Steps to Reproduce the Bug or Issue

i am unsure

Expected behavior

it should start

Screenshots or Videos

No response

Platform

"@tanstack/react-form": "^1.11.1", "@tanstack/react-query": "^5.71.10", "@tanstack/react-router": "^1.121.0", "@tanstack/react-router-with-query": "^1.121.0", "@tanstack/react-start": "^1.121.0", "@tanstack/react-start-config": "^1.120.20", "@tanstack/react-table": "8.21.2", "@tanstack/router-plugin": "^1.121.0",

OS: macOS 14.6.1 Memory: 16 GiB Architecture: aarch64

Additional context

app.config.ts: import { defineConfig } from "@tanstack/react-start-config"; import viteTsConfigPaths from "vite-tsconfig-paths"; import tailwindcss from "@tailwindcss/vite"; import { cloudflare } from "unenv"; import nitroCloudflareBindings from "nitro-cloudflare-dev";

export default defineConfig({ tsr: { appDirectory: "src", }, vite: { plugins: [ viteTsConfigPaths({ projects: ["./tsconfig.json"], }), tailwindcss(), ], },

react: { exclude: ["pg-cloudflare"], }, server: { preset: "cloudflare-module", unenv: cloudflare, modules: [nitroCloudflareBindings], }, });

erik-kroon avatar Jun 11 '25 10:06 erik-kroon

I getting issue same thing with this case, how to solve @erik-reges

irosadie avatar Jun 11 '25 13:06 irosadie

having the same issue.

lifeofcoding avatar Jun 11 '25 13:06 lifeofcoding

Getting same issue

import { CONSTANTS as GENERATOR_CONSTANTS, startAPIRouteSegmentsFromTSRFilePath, } from '@tanstack/router-generator'; ^^^^^^^^^ SyntaxError: The requested module '@tanstack/router-generator' does not provide an export named 'CONSTANTS' at ModuleJob.instantiate (node:internal/modules/esm/module_job:123:21) at async ModuleJob.run (node:internal/modules/esm/module_job:191:5) at async ModuleLoader.import (node:internal/modules/esm/loader:336:24) at async loadFile (file:///home/choopk/marvel/start-basic/node_modules/.pnpm/[email protected]@[email protected][email protected][email protected][email protected][email protected]_436a3a01fa7710d20032261ed993d844/node_modules/vinxi/lib/load-app.js:83:25) at async loadApp (file:///home/choopk/marvel/start-basic/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected]_436a3a01fa7710d20032261ed993d844/node_modules/vinxi/lib/load-app.js:137:19) at async Object.run (file:///home/choopk/marvel/start-basic/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected]_436a3a01fa7710d20032261ed993d844/node_modules/vinxi/bin/cli.mjs:76:17) at async runCommand (file:///home/choopk/marvel/start-basic/node_modules/.pnpm/[email protected]/node_modules/citty/dist/index.mjs:316:16) at async runCommand (file:///home/choopk/marvel/start-basic/node_modules/.pnpm/[email protected]/node_modules/citty/dist/index.mjs:307:11) at async runMain (file:///home/choopk/marvel/start-basic/node_modules/.pnpm/[email protected]/node_modules/citty/dist/index.mjs:445:7)

ERROR Cannot read properties of undefined (reading 'config') 11:30:42 PM

at Object.run (node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected]_436a3a01fa7710d20032261ed993d844/node_modules/vinxi/bin/cli.mjs:79:9)
at async runCommand (node_modules/.pnpm/[email protected]/node_modules/citty/dist/index.mjs:316:16)
at async runCommand (node_modules/.pnpm/[email protected]/node_modules/citty/dist/index.mjs:307:11)
at async runMain (node_modules/.pnpm/[email protected]/node_modules/citty/dist/index.mjs:445:7) 

choopk avatar Jun 11 '25 15:06 choopk

Same here. Our Clerk TanStack integration tests stopped working 👀

I had to pin the ff. versions in our e2e:

"dependencies": {
  "@tanstack/react-router": "1.120.17",
  "@tanstack/router-generator": "1.120.17",
  "@tanstack/react-router-devtools": "1.120.17",
  "@tanstack/react-start": "1.120.17",
  "@tanstack/react-start-config": "1.120.17",
  "@tanstack/router-plugin": "1.120.17",
  "@tanstack/react-start-client": "1.120.17",
  "@tanstack/react-start-plugin": "1.120.17",
  "@tanstack/react-start-server": "1.120.17",
  "@tanstack/start-server-core": "1.120.17",
  "@typescript-eslint/parser": "^7.18.0",
  "isbot": "^5.1.17",
  "react": "18.3.1",
  "react-dom": "18.3.1",
  "vinxi": "0.5.3"
},

This ensures that your node_modules will always resolve to a compatible set, avoiding the breaking changes until you are ready to migrate everything at once. If you skip one of them, then the lockfile/node_modules will resolve a mix of pre- and post-breaking-change versions

wobsoriano avatar Jun 11 '25 16:06 wobsoriano

Looking at the stack traces here, it looks like you haven't done the devinxi migration. From release v1.121.0, Start moved away from Vinxi and is now a Vite Plugin (which requires Vite 6+).

The linked migration guide should get you most of the way.

Edit: We're still tracking all the options that changes in the config and we'll update that soon.

SeanCassiere avatar Jun 11 '25 22:06 SeanCassiere

I had a similar issue with a different internal import:

--- import { generator, resolveConfigPath } from "@tanstack/router-generator";
--- SyntaxError: The requested module '@tanstack/router-generator' does not provide an export named 'generator'

It looks like router-generator's exports have changed quite substantially from 1.120 to 1.121, and generator is no longer exported - a breaking change.

However, the dependency-versioning strategy for using router-generator from, for instance, router-plugin is workspace:^:

https://github.com/TanStack/router/blob/bab29d0e88945fa72f55ca3284461bb47c550f50/packages/router-plugin/package.json#L114

... so in my case, my existing [email protected] had installed [email protected], which is incompatible.

Upgrading everything to 1.121 will fix the issues for me; pinning has worked for others. I'm sure there are other workarounds.

However, my question would be whether that workspace:^ versioning strategy is sound, given those breaking changes. Would workspace:* be more appropriate?

junglebarry avatar Jun 12 '25 07:06 junglebarry

Looking at the stack traces here, it looks like you haven't done the devinxi migration. From release v1.121.0, Start moved away from Vinxi and is now a Vite Plugin (which requires Vite 6+).

The linked migration guide should get you most of the way.

Edit: We're still tracking all the options that changes in the config and we'll update that soon.

https://tanstack.com/start/latest/docs/framework/react/hosting

The docs for cloudflare is not updated for the devinxi migration

choopk avatar Jun 14 '25 13:06 choopk

why is this closed

rushab-agi avatar Jun 26 '25 08:06 rushab-agi

I had a similar issue with a different internal import:

--- import { generator, resolveConfigPath } from "@tanstack/router-generator";
--- SyntaxError: The requested module '@tanstack/router-generator' does not provide an export named 'generator'

It looks like router-generator's exports have changed quite substantially from 1.120 to 1.121, and generator is no longer exported - a breaking change.

However, the dependency-versioning strategy for using router-generator from, for instance, router-plugin is workspace:^:

router/packages/router-plugin/package.json

Line 114 in bab29d0

"@tanstack/router-generator": "workspace:^", ... so in my case, my existing [email protected] had installed [email protected], which is incompatible.

Upgrading everything to 1.121 will fix the issues for me; pinning has worked for others. I'm sure there are other workarounds.

However, my question would be whether that workspace:^ versioning strategy is sound, given those breaking changes. Would workspace:* be more appropriate?

+1.

This is a super obscure bug. I'm quite behind on my router updates (sorry :() and I run into this exact same problem. I didn't know what this generator library was, there's no mention of it anywhere in the doc. They should either switch the versioning strategy for this one, or encourage people to install the package in the doc. @SeanCassiere you shouldn't close this issue. It's not only about the migration. Take the time to read the comment I quoted. There was a breaking change for people who were not ready to do the migration yet.

Also I want to state that the devinxi migration guide is super hard to follow.

https://github.com/TanStack/router/discussions/2863#discussioncomment-13104960

When I follow this link, it first mention the start package. I don't use the start package. So do I still need to proceed with the migration?

Then: npm uninstall vinxi npm install vite

I usually webpack. What do I do here? I don't even have vinxi installed, why should I have vinxi installed?

Update your scripts => All about vite again.

Moving from /app to /src => I'm covered on this.

You need src/router.tsx => Why? Do I have to do it even if I don't use any of the above?

Delete src/client.tsx and src/ssr.tsx => So now I'm even more confused. Is the devinxi migration only for people doing ssr? if so, why is it impacting me even if I don't do ssr?

Devinxi - Changes to your TanStack Start config => I don't use tanstack start.

Devinxi - Migrating from API Routes to Server Routes => See comment above about ssr.

Not migrating at this time => Some mention about pigging react-start. No mention of pinning the generator library.

Mboulianne avatar Jun 27 '25 12:06 Mboulianne

@Mboulianne sorry about all of this confusion. the vinxi->vite migration is indeed only relevant for people using TanStack Start

However, users using @tanstack/router-plugin unfortunately also need to either update that plugin OR pin the version of @tanstack/router-generator The reason for this is that @tanstack/router-plugin depended on @tanstack/router-generator but not an exact version, as we used the ^ range. this will pull in the newer version of the generator which is then not compatible anymore. I changed the dependency to be an exact version, but we can't fix this anymore for the already released versions.

schiller-manuel avatar Jun 27 '25 20:06 schiller-manuel

The migration guide says to get rid of app.config.ts but this docs page still has a reference to it https://tanstack.com/start/latest/docs/framework/react/path-aliases

BennyHinrichs avatar Sep 09 '25 17:09 BennyHinrichs

@BennyHinrichs good catch. want to fix that with a PR against the docs?

schiller-manuel avatar Sep 09 '25 17:09 schiller-manuel

I just hit this too. What's the workaround?

c4milo avatar Nov 25 '25 20:11 c4milo

@c4milo you probably need to bump the package versions.

schiller-manuel avatar Nov 25 '25 20:11 schiller-manuel

It didn't seem to work, so I went down the manual setup instead, which solved it. Thanks!

c4milo avatar Nov 25 '25 20:11 c4milo