Open HegarGarcia opened 1 year ago
I have the same problem in an nx monorepo. The fast solution/workaround I've implemented is: npm i -D tsconfig-paths ts-node
npx ts-node --project ./tsconfig.base.json -r tsconfig-paths/register node_modules/drizzle-kit/index.cjs generate:pg --config ./packages/
If you're using TS 5.0+ and cannot use ts-node, tsx also works well too:
tsx node_modules/drizzle-kit/index.cjs studio --config ./src/db/drizzle.config.ts
I have same problem in my project with Nx monorepo.
Met the same problem with a SvelteKit project and for some reason tsx
wouldn't account for the path aliases inside the root tsconfigs' "extends": "./.svelte-kit/tsconfig.json"
. A quick fix for the moment is to reference Sveltekit's generated config directly:
"scripts": {
"db:run": "tsx --tsconfig ./.svelte-kit/tsconfig.json node_modules/drizzle-kit/index.cjs",
"db:gen": "pnpm db:run generate:pg",
"db:studio": "pnpm db:run studio"
}
Note that for this to work in CI/CD flows, you have to build your sveltekit app first to generate the config.
Update: drizzle's team decided to move index.cjs
to bin.cjs
, so the above should now be:
"db:run": "tsx --tsconfig ./.svelte-kit/tsconfig.json node_modules/drizzle-kit/bin.cjs",
Same issue with using sveltekit($env/static/private)
Currently drizzle-kit doesn't support Typescript path aliases, this prevents the usage of the package on big codebases where most of the imports are through aliases.
Using absolute paths on the imports works without a problem, but when using any
@/...
path everything breaks. This also applies to thedrizzle.config.ts
.Right now I'm working around this problema by denying all imports not coming from
drizzle-orm
with ESLint but that is not a good solution long term.Leaving the snippet for anyone having issues with this.