zenstack: Generated "enhance" function not found. Please run zenstack generate first.

Description and expected behavior I started the development of a Nuxt application and after defining my zenstack schema, I wrote an API route for the server to retrieve a file entity from the database. But I get an error after having at the execution level of enhance(prisma). However I have already run npx zenstack generate and npx prisma db push.

Screenshots zmodel

Image

Image

global prisma client

Image

route api

Image

Environment (please complete the following information):

  • ZenStack version: 2.11.5
  • Prisma version: 6.3.x
  • Database type: Postgresql

Additional context I running nuxt with compatibility version 4

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 1
  • Comments: 22 (13 by maintainers)

Most upvoted comments

I made a few tries with node 20.19.0 as @sslotnick indicated:

  • tsx ran into the issue, @sslotnick 's workaround worked for me
  • Nuxt ran into the issue as @Kylyi reported
  • ts-node worked fine, compiling with tsc and then running directly with node worked fine
  • Next.js worked fine

So it seems later node versions broke something related loading ESM with require, however the issue only happens with certain bundler (nuxt) and nodejs loaders (tsx) …

I don’t have further insight into the issue so far, and please use @sslotnick 's workaround for now.

I just encountered this issue going from node 20.18.3 to 20.19.0. Using the flag --no-experimental-require-module fixes it.

$ pnpm tsx --version
tsx v4.19.3
node v20.19.0
$ pnpm tsx --no-experimental-require-module ./scripts/myscript.ts
...
$ pnpm tsx ./scripts/myscript.ts
...
        throw new Error('Generated "enhance" function not found. Please run `zenstack generate` first.');
              ^
...