T
TanStack6mo ago
wise-white

Path alias not working

Not sure if this is the right place for this but I'm having an issue with trying to use a Typescript path alias.
Error: Cannot find module '@/lib/theming' imported from 'D:/Git/tanstack-test/apps/www/src/routes/__root.tsx'
Error: Cannot find module '@/lib/theming' imported from 'D:/Git/tanstack-test/apps/www/src/routes/__root.tsx'
I've set up the path alias, the editor is picking up the right path (see hover-over in screenshot) and I've got the vite plugin for the tsconfig paths. app.config.ts
// app.config.ts
import tailwindcss from '@tailwindcss/vite'
import { defineConfig } from '@tanstack/react-start/config'
import tsConfigPaths from 'vite-tsconfig-paths'


export default defineConfig({
tsr: {
appDirectory: './src',
},

vite: {
plugins: [
tsConfigPaths({
projects: ['./tsconfig.json'],
}),
tailwindcss(),
],
},

react: {
babel: {
plugins: [
[
"babel-plugin-react-compiler",
{
target: "19",
},
],
],
},
},
})
// app.config.ts
import tailwindcss from '@tailwindcss/vite'
import { defineConfig } from '@tanstack/react-start/config'
import tsConfigPaths from 'vite-tsconfig-paths'


export default defineConfig({
tsr: {
appDirectory: './src',
},

vite: {
plugins: [
tsConfigPaths({
projects: ['./tsconfig.json'],
}),
tailwindcss(),
],
},

react: {
babel: {
plugins: [
[
"babel-plugin-react-compiler",
{
target: "19",
},
],
],
},
},
})
Anyone got any ideas? If I use a relative path to the lib file then it's fine. I'm definitely not new to TS but this one has me a little stumped.
No description
4 Replies
flat-fuchsia
flat-fuchsia6mo ago
can you try with WSL instead of "pure windows"?
wise-white
wise-whiteOP6mo ago
I can give it go. In the meantime, are there some known issues with Windows?
flat-fuchsia
flat-fuchsia6mo ago
no, but more often than not,path issues stem from windows being... different
wise-white
wise-whiteOP6mo ago
For whatever reason I can't even get the dependencies installed in wsl It's almost 1am, I'll come back to this tomorrow after work. Tried again this morning, for whatever reason git won't let me clone my own repo in wsl, despite having done it previously. I honestly don't have the energy to try and get that working right. Fwiw, though, my app is in a monorepo and the workspace aliases work without any issues. Just seems to have an issue trying to reference itself. Path aliases also work on other repos on my machine in anon-monorepo setup so I imagine if it's a pathing issue, it's probably a pathing issue with TanStack AND Windows in combination.

Did you find this page helpful?