Skip to main content
0 reactions

Fixed: “Conflicting configuration paths were found for the following routes” in TanStack Start

Card titled Conflicting configuration paths were found, labelled Fixed, TanStack Start, with a warning sign and two facts: index.js beside index.tsx gives a conflict, and noEmit set to true stops the copies.
Fixed: Conflicting configuration paths were found for the following routes in TanStack Start

If the TanStack Start dev server prints “Error: Conflicting configuration paths were found for the following routes”, and the conflicting files come in pairs such as index.js and index.tsx, the TypeScript compiler wrote a JavaScript copy next to each of your files. This post shows where the copies come from, and the fix: delete them, and set noEmit so that tsc never writes them again.

What I Was Doing

I was writing How to Link to a Route with Path Params in TanStack Start, with a small TanStack Start app set up by hand as in How to Build a TanStack Start App from Scratch Without the CLI. Its dev server was running in one terminal, and in another I checked the app’s types:

TerminalBash
npx tsc
OutputPlain text
npm notice run tanstack-start-starter@1.0.0 npx
npm notice run 'tsc'

It reported no type errors.

What I Expected

The type check to report type errors, if there were any, and change nothing, while the dev server kept running quietly.

What I Got

The terminal running the dev server printed this error, three times in a row:

Output (paths shortened to …)Plain text
  VITE v8.3.8  ready in 694 ms

  ➜  Local:   http://localhost:3101/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help
5:13:13 PM [vite] (ssr) connected.
Error: Conflicting configuration paths were found for the following routes: "/", "/", "/hello/$name", "/hello/$name".
Please ensure each Route has a unique full path.
Conflicting files: 
 …/src/routes/index.js
 …/src/routes/index.tsx
 …/src/routes/hello/$name.js
 …/src/routes/hello/$name.tsx

    at file://…/node_modules/@tanstack/router-generator/dist/esm/generator.js:143:13
A terminal where the running dev server prints Error: Conflicting configuration paths were found for the following routes, with the conflicting files index.js, index.tsx, $name.js and $name.tsx.
The dev server’s terminal after npx tsc wrote .js copies of the route files.

The last line names the part that failed: TanStack Router’s route generator, which reads src/routes and writes the app’s list of routes, src/routeTree.gen.ts. The dev server kept running.

What I Checked

The conflicting files come in pairs: index.js with index.tsx, and $name.js with $name.tsx. The .js files weren’t there before the type check. The app’s tsconfig.json, which has the settings from TanStack’s Build a Project from Scratch (opens in a new tab) guide, has no noEmit option:

tsconfig.jsonJSON
{
  "compilerOptions": {
    "jsx": "react-jsx",
    "moduleResolution": "Bundler",
    "module": "ESNext",
    "target": "ES2022",
    "skipLibCheck": true,
    "strictNullChecks": true
  }
}

Without it, tsc doesn’t only check the code, it also compiles it. TypeScript’s outDir (opens in a new tab) reference says that when no output folder is set, “.js files will be emitted in the same directory as the .ts files”.

Why It Happens

TanStack Start makes a route from every route file in src/routes, and a .js file counts as one. When tsc wrote a .js copy of each route file, every route had two files with the same path, which the route generator refuses: “Please ensure each Route has a unique full path.”

An app made with the TanStack CLI doesn’t run into this, because its tsconfig.json sets "noEmit": true.

The Fix

  1. Delete the .js files that tsc wrote: each .js file with a .ts or .tsx file of the same name beside it. In this app, they were vite.config.js, src/router.js, src/routeTree.gen.js, src/routes/__root.js, src/routes/index.js and src/routes/hello/$name.js. Delete them in your code editor’s file list. A .js file with no .ts or .tsx twin is your own, so keep it.
  2. Tell tsc to only check the code: in tsconfig.json, add "noEmit": true to compilerOptions.
  3. Stop the dev server with Ctrl+C, and start it again with npm run dev.

tsconfig.json after step 2:

tsconfig.jsonJSON
{
  "compilerOptions": {
    "jsx": "react-jsx",
    "moduleResolution": "Bundler",
    "module": "ESNext",
    "target": "ES2022",
    "skipLibCheck": true,
    "strictNullChecks": true,
    "noEmit": true
  }
}

Don’t skip vite.config.js. Vite looks for vite.config.js before vite.config.ts (DEFAULT_CONFIG_FILES in Vite’s source (opens in a new tab)), so it would keep loading the old copy after you change vite.config.ts.

Or Check the Types with –noEmit

To leave tsconfig.json as it is, add the option to the command each time instead. It checks the types and writes nothing:

TerminalBash
npx tsc --noEmit

After the Fix

The dev server starts without the error. Running the type check again writes no files, and the dev server’s terminal stays quiet:

TerminalBash
npx tsc
OutputPlain text
npm notice run tanstack-start-starter@1.0.0 npx
npm notice run 'tsc'
A terminal where the dev server is ready on a local address and connected, with no error after the type check.
After the fix, the type check writes no files and the dev server stays quiet.

Common Mistakes

MistakeWhat happensDo this instead
Deleting the .tsx files instead of the .js copiesYour own code is goneDelete only the .js files that have a .ts or .tsx twin
Keeping vite.config.jsVite loads it instead of vite.config.ts, so later changes to vite.config.ts don’t applyDelete vite.config.js too
Adding noEmit without deleting the copiesThe copies stay, and so does the errorDelete them as well

Troubleshooting

ProblemFix
The error comes back after the next type checkCheck that "noEmit": true is inside compilerOptions.
The error still shows after you deleted the copiesStop the dev server with Ctrl+C and start it again.

FAQ

Is it safe to set noEmit in a TanStack Start app? Yes. Vite builds the app from the .ts and .tsx files itself, so tsc never needs to write JavaScript. Apps made with the TanStack CLI set it from the start.

What does noEmit do? It stops tsc from writing output files, such as JavaScript, so TypeScript only checks your code (noEmit (opens in a new tab) in the TypeScript reference).

Conclusion

A plain tsc in an app without noEmit writes a .js twin for every file, and TanStack Start then finds two files for each route. Delete the twins, set "noEmit": true, and the type check only checks.

Additional Resources

TanStack, React and other names mentioned are trademarks of their respective owners. JD Bots isn’t affiliated with or endorsed by TanStack.

0 comments