Skip to content

[Bug]: AdminJs not working with Prisma 6.8.x #1758

@s-lukashenka-micoworks

Description

@s-lukashenka-micoworks

Contact Details

s.lukashenka@micoworks.jp

What happened?

In Prisma v6.8.x the prisma client is imported from the generated code like below:

import { PrismaClient } from './generated/prisma'

Building the project gives the following error:

SyntaxError: The requested module '@prisma/client' does not provide an export named 'Prisma'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:146:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:229:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:473:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)

which is originating from the following AdminJs code:

import { Prisma } from '@prisma/client';
export const getEnums = (clientModule) => {
    const dmmf = clientModule?.Prisma.dmmf.datamodel ?? Prisma.dmmf.datamodel;
    return dmmf.enums.reduce((memo, current) => {
        // eslint-disable-next-line no-param-reassign
        memo[current.name] = current;
        return memo;
    }, {});
};

Please, advise how to work around it.

Bug prevalence

100% of time when building my project

AdminJS dependencies version

"@adminjs/design-system": "^4.1.1"
"@adminjs/express": "^6.1.1"
"@adminjs/prisma": "^5.0.3"

What browsers do you see the problem on?

No response

Relevant log output

SyntaxError: The requested module '@prisma/client' does not provide an export named 'Prisma'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:146:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:229:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:473:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)

Relevant code that's giving you issues

import { Prisma } from '@prisma/client';
export const getEnums = (clientModule) => {
    const dmmf = clientModule?.Prisma.dmmf.datamodel ?? Prisma.dmmf.datamodel;
    return dmmf.enums.reduce((memo, current) => {
        // eslint-disable-next-line no-param-reassign
        memo[current.name] = current;
        return memo;
    }, {});

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions