Open deadcoder0904 opened 1 year ago
Any updates on that?
drizzle.config.ts
doesn't have a way to follow your path aliases because it doesn't know about them. It depends on how you are running the script. The workaround will depend on if you're running it with ts-node
, tsc
, tsx
or any other. You probably just need to point the script runner/transpiler to your tsconfig.json
.
@Angelelz how do i do that then?
i already have this in my package.json
scripts:
"db:push": "drizzle-kit push:mysql --config drizzle.config.ts",
"db:generate": "drizzle-kit generate:mysql --config drizzle.config.ts",
"db:studio": "drizzle-kit studio --host localhost --port 3001 --verbose --config drizzle.config.ts",
all i do is pnpm run db:push
so idk how tsc
and the likes come into play.
This is how I'm doing:
"db:generate": "ts-node -r tsconfig-paths/register --project ./tsconfig.json ./node_modules/drizzle-kit/index.cjs generate:pg --config ./drizzle.config.ts"
This is how I'm doing:
"db:generate": "ts-node -r tsconfig-paths/register --project ./tsconfig.json ./node_modules/drizzle-kit/index.cjs generate:pg --config ./drizzle.config.ts"
I honestly just used relative paths and called it a day, lol. Drizzle kit just need the schema and the migration folder. I felt like an alias for those wasn't necessary. So there you go.
you're right @Angelelz!
thank you @matheuspuel for the solution but i'll stick with relative paths.
i always followed 1 right way of doing things for 10 years now. i guess its time to drop bad habits with whatever works. not gonna install ts-node
ha.
still keeping this one open if drizzle team finds a solution.
still keeping this one open if drizzle team finds a solution.
I agree with this. Maybe they can include an option to point to the tsconfig.json
?
To make it easier, we need to actively utilize type import and place important codes such as validation near schema. It may be quite a jarring arrangement if you use nosql or the others that cant reached drizzle.
This works for me now, at least, in combination with @t3-oss/env-nextjs
See https://github.com/deadcoder0904/drizzle-t3-oss-env/blob/main/drizzle.config.ts#L5
this also happens with sveltekit's $lib alias,
Error: Cannot find module '$lib/utils/mymodule'
This is more of a TS issue than a Drizzle one. We'll keep track of this as I do think this should be mentioned in the docs.
What version of
drizzle-orm
are you using?^0.28.6
What version of
drizzle-kit
are you using?^0.19.13
Describe the Bug
if i import using
'@/app/lib/env'
, it doesn't work but if i import using'./src/app/lib/env'
, it works.for example, this works fine:
drizzle.config.ts
but the following throws an error
Error: Cannot find module '@/app/lib/env'
:drizzle.config.ts
my
env
file looks like this:lib/env.ts
Expected behavior
this should work.
drizzle.config.ts
Environment & setup
windows 10!
my tsconfig looks like:
tsconfig.json