URL_INVALID

The env variables are defined when using bun run push but not when using npm run push or pnpm run push, resulting in LibsqlError: URL_INVALID: The URL is not in a valid format because url is undefined?authToken=undefined
export default {
schema: "./src/db/schema.ts",
out: "./src/db/migrations",
driver: "libsql",
dbCredentials: {
url: `${process.env.DATABASE_URL}?authToken=${process.env.DATABASE_TOKEN}`,
},
} satisfies Config
export default {
schema: "./src/db/schema.ts",
out: "./src/db/migrations",
driver: "libsql",
dbCredentials: {
url: `${process.env.DATABASE_URL}?authToken=${process.env.DATABASE_TOKEN}`,
},
} satisfies Config
{
"scripts": {
"push": "drizzle-kit push:sqlite"
},
// ...
}
{
"scripts": {
"push": "drizzle-kit push:sqlite"
},
// ...
}
Solution:
bun parsed the .env file automatically but node does not. You need you use dotenv or something similar when using pnpm/npm/yarn
Jump to solution
4 Replies
Solution
Angelelz
Angelelz15mo ago
bun parsed the .env file automatically but node does not. You need you use dotenv or something similar when using pnpm/npm/yarn
Dayblox
DaybloxOP14mo ago
How come the docs don't show this? And shouldn't drizzle-kit abstract this away?
Angelelz
Angelelz14mo ago
How do you think drizzle-kit should abstract away the environment variables to connect to your database?
Dayblox
DaybloxOP14mo ago
I meant reading the env variables with dotenv or some equivalent But now that I think about it, probably not drizzle-kit's responsibility
Want results from more Discord servers?
Add your server