T
TanStack•6mo ago
extended-salmon

500 error creating API route

Trying to create my first API route. 1. I added /app/api.ts as noted here: https://tanstack.com/start/latest/docs/framework/react/api-routes#setting-up-the-entry-handler 2. ) I added /app/api/hello.ts with the example code:
import { createAPIFileRoute } from '@tanstack/react-start/api'

export const APIRoute = createAPIFileRoute('/api/hello')({
GET: async ({ request }) => {
return new Response('Hello, World! from ' + request.url)
},
})
import { createAPIFileRoute } from '@tanstack/react-start/api'

export const APIRoute = createAPIFileRoute('/api/hello')({
GET: async ({ request }) => {
return new Response('Hello, World! from ' + request.url)
},
})
3. Then I restarted the dev server (a bunch of times) using "dev": "vinxi dev" as my package.json script. 500 error
[vite] Error when evaluating SSR module $vinxi/handler/api: failed to import "@tanstack/react-start/api"
|- Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './routes' is not defined by "exports" in /Users/me/myproj/node_modules/@tanstack/start-api-routes/node_modules/vinxi/package.json

[unhandled] Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './routes' is not defined by "exports" in /Users/me/myproj/node_modules/@tanstack/start-api-routes/node_modules/vinxi/package.json imported from /Users/me/myproj/node_modules/@tanstack/start-api-routes/dist/esm/index.js
at exportsNotFound (node:internal/modules/esm/resolve:314:10)
...
[vite] Error when evaluating SSR module $vinxi/handler/api: failed to import "@tanstack/react-start/api"
|- Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './routes' is not defined by "exports" in /Users/me/myproj/node_modules/@tanstack/start-api-routes/node_modules/vinxi/package.json

[unhandled] Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './routes' is not defined by "exports" in /Users/me/myproj/node_modules/@tanstack/start-api-routes/node_modules/vinxi/package.json imported from /Users/me/myproj/node_modules/@tanstack/start-api-routes/dist/esm/index.js
at exportsNotFound (node:internal/modules/esm/resolve:314:10)
...
Suggestions? Versions:
"@tanstack/react-query": "^5.59.20",
"@tanstack/react-router": "^1.82.1",
"@tanstack/react-router-with-query": "^1.82.1",
"@tanstack/react-start": "^1.114.22",
"@tanstack/start": "^1.82.1",
"@tanstack/react-query": "^5.59.20",
"@tanstack/react-router": "^1.82.1",
"@tanstack/react-router-with-query": "^1.82.1",
"@tanstack/react-start": "^1.114.22",
"@tanstack/start": "^1.82.1",
API Routes | TanStack Start React Docs
API Routes are a powerful feature of TanStack Start that allow you to create server-side endpoints in your application without the need for a separate server. API Routes are useful for handling form s...
7 Replies
national-gold
national-gold•6mo ago
Please switch to @tanstack/react-start. There's probably an issue with the exports in the old package. The old package will be going away soon anyways.
extended-salmon
extended-salmonOP•6mo ago
That worked! Ty! I fixed it in my version and will let convex, whose template I started with know to update it there too
national-gold
national-gold•6mo ago
You mind pointing me to the template? I'd rather contribute the fix for them, without having to create work for them.
extended-salmon
extended-salmonOP•6mo ago
It's the one installed from here: npm create convex@latest -- -t tanstack-start https://docs.convex.dev/quickstart/tanstack-start Tom from Convex sharing a link to the repo https://discord.com/channels/1019350475847499849/1280662562152644660/1351260622293041254
national-gold
national-gold•6mo ago
Ah! Tom (@ballingt) is on it. šŸš€ šŸ‘šŸ¼
optimistic-gold
optimistic-gold•6mo ago
Thanks @Sean Cassiere, you're all doing so much good work it's hard to keep up with šŸ˜†
national-gold
national-gold•6mo ago
sry šŸ˜… I'll ping you once we're done with Devinxi. So we can get the examples updated on the convex side of things.

Did you find this page helpful?