supanuxt-saas
supanuxt-saas copied to clipboard
Nuxt update to verbatimModuleSyntax breaks prisma seeding 'ESM syntax is not allowed'
Nuxt has changed to verbatimModuleSyntax True
look in this file...
.nuxt/tsconfig.json
and you will see this..
"verbatimModuleSyntax": true,
This breaks prisma DB seeding i.e. this..
npx prisma db push
gives you an error like this
ESM syntax is not allowed in a CommonJS module when 'verbatimModuleSyntax' is enabled.
then some bullshit with node types being missing "process can't be found'
I have fixed this in a downstream project by doing the following. Not sure if I should bring it back to the main repo or if it is the best fix.....
I needed to add this to .tsconfig (for the missing process bullshit)
"compilerOptions": {
"types": ["node"]
}
change to this in package.json
"prisma": {
"seed": "ts-node prisma/seed.ts"
},
and do this in seed.ts
const { PrismaClient } = require('@prisma/client');
I had a similar issue and could not seed into Supabase DB. I switched ts-node with tsx, and it worked fine.
in package.json
"prisma": {
"seed": "pnpx tsx prisma/seed.ts"
}
Agree with the tsx usage, minimal and in place replacement just works fine.
@wireless25 @mubaidr did you consider using vite-node? .... because it works good for me
"prisma": {
"seed": "npx vite-node prisma/seed.ts"
},
@wireless25 @mubaidr did you consider using vite-node? .... because it works good for me
"prisma": { "seed": "npx vite-node prisma/seed.ts" },
I did not, no. Didn't know this is a thing 😅 @JavascriptMick