I'm building a backend using Prisma, Postgres 14.5, Node 18, and Typescript. Every time try to seed the DB I get the following:
└ ➜ yarn prisma db seed
Environment variables loaded from .env
Running seed command `ts-node prisma/seed.ts` ...
An error occurred while running the seed command:
Error: Command failed with ENOENT: ts-node prisma/seed.ts
spawn ts-node ENOENT
ENOENT errors mean "No such file or directory"
I have this in my package.json
:
"prisma": {
"seed": "ts-node prisma/seed.ts"
},
My seed file is located at prisma/seed.ts
and contains:
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function main() {
const person = await prisma.name.upsert({
where: { id: 0 },
update: {},
create: {
firstName: 'Sakiko',
},
});
}
main()
.then(async () => {
await prisma.$disconnect();
})
.catch(async (e) => {
console.error(e);
await prisma.$disconnect();
process.exit(1);
});