Typescript path alias not working properly
I'm new to Drizzle, but I'm not able to use the path alias on schema files.
Using absolute paths on the imports works without a problem, but when using any
@/...
path everything breaks.
Right now I'm working around this problema by denying @/
imports wit ESLint but that is not a good solution long term.9 Replies
This also applies for the
drizzle.config.ts
Ever find a solution other than relative imports?
Make sure that the rules on your bundler apply in the folder/files where you are having those issues.
Also, if you are running tsc vs ts-node vs tsx to run drizzle kit commands they may or may not see your tsconfig
I'm using vite with tsconfigPaths, but admittadly don't know much about that stuff. The issue I'm having is when trying to generate migrations and the schema uses path alias for importing consts.
I guess it's specifically a drizzle-kit thing as the bundler isn't doing anything for migration generation
Can you type the command you use to run drizzle-kit migrate?
Drizzle-kit is not a standalone command, you must be using tsc, ts-node or any other Typescript runned
pnpm drizzle-kit generate:mysql
There go you, pnpm is not going to look at your tsconfig and resolve the paths
@ulic.75 You can do this:
@poisnfang huzzah! That is fantastic. Thank you so much.