-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Open
Labels
accepting-prsIdentifies issues/proposals that we are accepting community PRs forIdentifies issues/proposals that we are accepting community PRs forbugfeat:routes.tspkg:@react-router/dev
Description
I'm using React Router as a...
framework
Reproduction
Go to https://stackblitz.com/edit/github-93cysh5j
In terminal run npm run routes
or npm run dev
.
What did I do in that stack blitz:
- I moved root and entry files to subdirectory
app/core
- I kept routes folder in
app/routes
- I used flatRoutes package in
app/core/routes.ts
and pointed it at../routes
System Info
System:
OS: macOS 14.5
CPU: (10) arm64 Apple M1 Max
Memory: 1.36 GB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.15.0 - ~/.asdf/installs/nodejs/20.15.0/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 10.7.0 - ~/.asdf/plugins/nodejs/shims/npm
pnpm: 10.4.1 - /opt/homebrew/bin/pnpm
Watchman: 2024.12.02.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 133.0.6943.126
Safari: 17.5
npmPackages:
@react-router/dev: ^7.0.0 => 7.2.0
@react-router/fs-routes: ^7.1.5 => 7.2.0
@react-router/node: ^7.0.0 => 7.2.0
@react-router/serve: ^7.0.0 => 7.2.0
react-router: ^7.0.0 => 7.2.0
vite: ^6.1.0 => 6.1.0
Used Package Manager
npm
Expected Behavior
You expect the app to start. And you expect this this file to be loaded:
path: '/home/projects/github-93cysh5j/app/routes/home.tsx'
Actual Behavior
But you actually see this being loaded:
path: '/home/projects/github-93cysh5j/app/core/s/home.tsx'
Notice how route
was replaced with core/
?
This seems to be result of this line
file: file.slice(appDirectory.length + 1), |
/home/projects/github-93cysh5j/app/routes/home.tsx
-/home/projects/github-93cysh5j/app/route
+/home/projects/github-93cysh5j/app/core/
=/home/projects/github-93cysh5j/app/core/s/home.tsx
rtbenfield
Metadata
Metadata
Assignees
Labels
accepting-prsIdentifies issues/proposals that we are accepting community PRs forIdentifies issues/proposals that we are accepting community PRs forbugfeat:routes.tspkg:@react-router/dev
Activity
rtbenfield commentedon Jul 1, 2025
I ran into this one as well. It looks like it's caused by attempting to remove the app directory path from the file absolute path using
.slice(appDirectory.length + 1)
here, which assumes the route is somewhere under the app directory.