I am building a Nuxt application and hosting it on digitalOcean.
I am using Prisma as ORM.
We have a Users table, and this User can have a Role which is of enum type Roles
. But for some reason I am not able to import the Roles
type which is in the generated Nuxt
import { Roles, PrismaClient } from '@prisma/client';
SyntaxError: Named export ‘Roles’ not found. The requested module ‘@prisma/client’ is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from '@prisma/client';
const { Roles, PrismaClient } = pkg;
I am not able to import it this way because the file is generated automatically.
It works fine locally, I have tried the following things:
- Force rebuild and deploy in digitalOcean app
- Set prisma client to different output location
- Move prisma from
devDepenencies
todependencies
- Compared node versions
- Compared Prisma versions
- made sure to run
npx prisma generate
andnpx prisma migrate deploy
straight after runningnpm run build
- Resetting the database
NOTE: Before adding the Roles
enum to the code, I always got the following error while running the production environment, even though I had run npx prisma generate
adter npm run build
:
@prisma/client did not initialize yet. Please run “prisma generate” and try to import it again.
Any help would be appreciated