I’m trying to seed my database using Prisma’s official CLI, but I’m encountering an unexpected error when running npx prisma db seed
. My project was set up using the official Prisma CLI, and I’m following their documentation, yet I’m getting a file extension error that seems bizarre.
Error message
TypeError: Unknown file extension ".ts" for /path/to/prisma/seed.ts
at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:218:9)
...
My package.json
Seed Configuration:
"prisma": {
"seed": "ts-node prisma/seed.ts"
}
However, It does work with when installing tsx
and modifying it to:
"prisma": {
"seed": "tsx prisma/seed.ts"
}
I’m frustrated because I’m using Prisma’s official CLI and documentation. Why do I have to tweak the setup to make it work? Shouldn’t it work out of the box?