prisma db seed doesn't correctly support `"type": "module"`
See original GitHub issueProblem
When you enable module resolution with "type": "module"
on your projet the prisma db seed
command fail due to ts-node resolution.
➜ yarn prisma db seed --preview-feature
yarn run v1.22.10
$ /path-to-my-project/node_modules/.bin/prisma db seed --preview-feature
Environment variables loaded from prisma/.env
Prisma schema loaded from prisma/schema.prisma
Running ts-node "prisma/seed.ts" ...
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /path-to-my-project/play-prisma-sqlite/prisma/seed.ts
at new NodeError (node:internal/errors:329:5)
at Loader.defaultGetFormat [as _getFormat] (node:internal/modules/esm/get_format:71:15)
at Loader.getFormat (node:internal/modules/esm/loader:104:42)
at Loader.getModuleJob (node:internal/modules/esm/loader:242:31)
at Loader.import (node:internal/modules/esm/loader:176:17)
at Object.loadESM (node:internal/process/esm_loader:68:5)
Error: Command failed with exit code 1: ts-node "prisma/seed.ts"
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Suggested solution
When "type": "module"
is detected: instead of running ts-node "prisma/seed.ts"
you can use the node loader node --loader ts-node/esm "prisma/seed.ts"
Alternatives
N/A
Additional context
Project example https://github.com/ghoullier/esm-prisma-seed
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
prisma db seed & typescript problem with import and type ...
Try and double-check your seed command in the prisma section of your package.json, it should look like the one in the repo of...
Read more >Seeding your database - Prisma
This guide describes how to seed your database using Prisma Client and Prisma's integrated seeding functionality. Seeding allows you to consistently ...
Read more >Prisma | NestJS - A progressive Node.js framework
Prisma currently supports PostgreSQL, MySQL, SQL Server, SQLite, ... a sample NestJS application with a REST API that can read and write data...
Read more >Hey all I m having issues with seeding data with Prisma and
Hey all I m having issues with seeding data with Prisma and ... I was also hopeful module type overrides would help, but...
Read more >How to Get Started with Prisma ORM for Node.js and ...
js framework and PostgreSQL database. We will build a simple Quotes REST API to add and serve up programming-related quotes. Let's get started!...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is temp case, you can run seed, but
--preview-feature
not work:If your seed file in at your project
prisma/seed.ts
.1 - Install esbuild in your project
2 - Add
seed
in yourpackage.json
scripts:3 - Run seed script
It works in my project, hope you can run it.
🗒️ We heard the feedback and we are planning a redesign of
db seed
(currently planned to be released early September)How it will work is that a
prisma.seed
property in the package.json of your project will be required if you want to useprisma db seed
.This property is where you will be able to put any command you want to execute your seed script.
More info/details & how to try it out now in: https://github.com/prisma/prisma/issues/8732