supanuxt-saas icon indicating copy to clipboard operation
supanuxt-saas copied to clipboard

Nuxt update to verbatimModuleSyntax breaks prisma seeding 'ESM syntax is not allowed'

Open JavascriptMick opened this issue 1 year ago • 4 comments

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');

JavascriptMick avatar Dec 09 '23 22:12 JavascriptMick

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"
}

wireless25 avatar Mar 08 '24 13:03 wireless25

Agree with the tsx usage, minimal and in place replacement just works fine.

mubaidr avatar Mar 21 '24 08:03 mubaidr

@wireless25 @mubaidr did you consider using vite-node? .... because it works good for me

  "prisma": {
    "seed": "npx vite-node prisma/seed.ts"
  },

JavascriptMick avatar Jun 16 '24 01:06 JavascriptMick

@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

wireless25 avatar Jul 25 '24 18:07 wireless25