Hi folks, I am stuck on Prisma seed: When I run th...
# orm-help
t
Hi folks, I am stuck on Prisma seed: When I run the command
npx prisma migrate reset --force
/
npx prisma db seed
, it gives me the following error. No idea what to do. Been searching for a solution. Please help.
Using sqlite
seed.ts
Copy code
import { users } from "./seeds/users";
import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();

async function main() {
  for (let user of users) {
    await prisma.user.create({
      data: {
        ...user,
      },
    });
  }
}

main().catch((e) => {
  console.log(e, "error")
  process.exit(1)
}).finally(async () => {
  await prisma.$disconnect();
});
Data file - users.ts
Copy code
const users = [
  {
    firstName: 'John',
    lastName: 'Doe',
    userName: 'johndoe',
    avatar: '<https://avatars0.githubusercontent.com/u/17098?v=4>',
    authLevel: 'L4'
  }
]

export { users }
j
How do you have
ts-node
installed in your app? Can you just execute
ts-node
? You might need to replace the command with
npx ts-node
if you do not have a global install.
(FYI @Joël)