Open kasir-barati opened 2 years ago
Which version of pnpm are you using? (might help to reproduce)
Which version of pnpm are you using? (might help to reproduce)
@Jolg42
$ pnpm -v
6.32.3
Right now latest versions - ATM: 2022-06-08 - is 7.1.9
. Probably help. BTW I am gonna upgrade my pnpm version and retry to see if the bug persist or it will goes away.
@Jolg42 After Upgrading pnpm to latest version - ATM latest version is 7.1.9
- the problem does not resolved.
I could not reproduce on Codespaces
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.4 LTS
Release: 20.04
Codename: focal
This is what I get after following the reproduction steps:
Which point here
/workspaces/basic-prisma-nestjs-restful-api/node_modules/.pnpm/@prisma+client@3.14.0_prisma@3.14.0/node_modules/.prisma/client/index.d.ts
Does this path exist for you? node_modules/.pnpm/@prisma+client@3.14.0_prisma@3.14.0/node_modules/.prisma/client/
You could try to delete the node_modules
and pnpm i
, also try restarting your IDE.
Note that there is a package-lock.json and a pnpm-lock.yaml file and that might end up with different results if mixinf npm and pnpm.
@Jolg42 OK but I have the error. I guess you are on mac :confused: BTW I have this problem.
I'm indeed on macOS but here I tested with GitHub Codespaces which is on Ubuntu 20.04.4 LTS
Did you try what I suggested?
Hi @Jolg42
I have the same issue with this repository I'm working on: https://github.com/richardwardza/prisma-lambda-layers
If I use pnpm
then I also get Module '"@prisma/client"' has no exported member 'PrismaClient'.ts(2305)
on my import { PrismaClient } from '@prisma/client';
This is after the prisma generate
has run:
src/layers/prisma postinstall$ prisma generate
│ Environment variables loaded from .env
│ Prisma schema loaded from prisma/schema.prisma
│ ✔ Generated Prisma Client (3.15.1 | library) to ./../../../node_modules/.pnpm/@prisma+client@3.15.1_prisma@3.15.1/node_modules/@prisma/client in 385ms
│ You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client
│ ```
│ import { PrismaClient } from '@prisma/client'
│ const prisma = new PrismaClient()
│ ```
The node_modules/.pnpm/@prisma+client@3.15.1_prisma@3.15.1/node_modules/@prisma/client
directory does exist and has the following:
richard:bison hello > l node_modules/.pnpm/@prisma+client@3.15.1_prisma@3.15.1/node_modules/@prisma/client
total 88
-rw-r--r-- 4 richard staff 11357 Jun 9 21:14 LICENSE
-rw-r--r-- 3 richard staff 2561 Jun 9 21:14 README.md
-rw-r--r-- 5 richard staff 31 Jun 9 21:14 edge.d.ts
-rw-r--r-- 3 richard staff 58 Jun 9 21:14 edge.js
drwxr-xr-x 3 richard staff 96 Jun 9 23:46 generator-build
-rw-r--r-- 3 richard staff 80 Jun 9 21:14 index-browser.js
-rw-r--r-- 5 richard staff 31 Jun 9 21:14 index.d.ts
-rw-r--r-- 3 richard staff 59 Jun 9 21:14 index.js
drwxr-xr-x 3 richard staff 96 Jun 9 23:46 node_modules
-rw-r--r-- 2 richard staff 6841 Jun 9 21:14 package.json
drwxr-xr-x 7 richard staff 224 Jun 9 23:46 runtime
drwxr-xr-x 11 richard staff 352 Jun 9 23:46 scripts
If I go to the src/layers/prisma
directory and run rm -rf node_modules
and then npm i
then the packages get installed and prisma client is generated to ./node_modules/@prisma/client
which has:
richard:bison prisma > l ./node_modules/@prisma/client
total 88
-rw-r--r-- 1 richard staff 11357 Oct 26 1985 LICENSE
-rw-r--r-- 1 richard staff 2561 Oct 26 1985 README.md
-rw-r--r-- 1 richard staff 31 Oct 26 1985 edge.d.ts
-rw-r--r-- 1 richard staff 58 Oct 26 1985 edge.js
drwxr-xr-x 3 richard staff 96 Jun 10 00:00 generator-build
-rw-r--r-- 1 richard staff 80 Oct 26 1985 index-browser.js
-rw-r--r-- 1 richard staff 31 Oct 26 1985 index.d.ts
-rw-r--r-- 1 richard staff 59 Oct 26 1985 index.js
-rw-r--r-- 1 richard staff 5279 Jun 10 00:00 package.json
drwxr-xr-x 7 richard staff 224 Jun 10 00:00 runtime
drwxr-xr-x 11 richard staff 352 Jun 10 00:00 scripts
and in my IDE the PrismaClient
is imported correctly.
I'm on a MAC
and using pnpm 7.1.9
and prisma 3.15.1
With pnpm
my ./node_modules/.bin/prisma -v
shows:
richard:bison prisma > ./node_modules/.bin/prisma -v
Environment variables loaded from .env
prisma : 3.15.1
@prisma/client : 3.15.1
Current platform : darwin
Query Engine (Node-API) : libquery-engine 461d6a05159055555eb7dfb337c9fb271cbd4d7e (at ../../../node_modules/.pnpm/@prisma+engines@3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e/node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine : migration-engine-cli 461d6a05159055555eb7dfb337c9fb271cbd4d7e (at ../../../node_modules/.pnpm/@prisma+engines@3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e/node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core 461d6a05159055555eb7dfb337c9fb271cbd4d7e (at ../../../node_modules/.pnpm/@prisma+engines@3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e/node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary : prisma-fmt 461d6a05159055555eb7dfb337c9fb271cbd4d7e (at ../../../node_modules/.pnpm/@prisma+engines@3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e/node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash : 461d6a05159055555eb7dfb337c9fb271cbd4d7e
Studio : 0.462.0
and with npm
is has:
Environment variables loaded from .env
prisma : 3.15.1
@prisma/client : 3.15.1
Current platform : darwin
Query Engine (Node-API) : libquery-engine 461d6a05159055555eb7dfb337c9fb271cbd4d7e (at node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine : migration-engine-cli 461d6a05159055555eb7dfb337c9fb271cbd4d7e (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core 461d6a05159055555eb7dfb337c9fb271cbd4d7e (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary : prisma-fmt 461d6a05159055555eb7dfb337c9fb271cbd4d7e (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash : 461d6a05159055555eb7dfb337c9fb271cbd4d7e
Studio : 0.462.0
I did try your suggestion of "delete the node_modules and pnpm i, also try restarting your IDE." but that didn't help.
This is the first time I'm using pnpm
so I'm not 100% sure I have it setup correctly with the pnpm-workspace.yaml
file.
hhm - I don't get a node_modules/.prisma
directory generated.
prisma generate
creates it in ./../../../node_modules/.pnpm/@prisma+client@3.15.1_prisma@3.15.1/node_modules/@prisma/client
Generated Prisma Client (3.15.1 | library) to ./../../../node_modules/.pnpm/@prisma+client@3.15.1_prisma@3.15.1/node_modules/@prisma/client
but nothing in node_modules, only:
drwxr-xr-x 22 richard staff 704 Jun 10 17:33 .
drwxr-xr-x 15 richard staff 480 Jun 10 17:24 ..
drwxr-xr-x 12 richard staff 384 Jun 10 17:24 .bin
drwxr-xr-x 3 richard staff 96 Jun 10 17:24 @prisma
drwxr-xr-x 4 richard staff 128 Jun 10 17:24 @types
drwxr-xr-x 4 richard staff 128 Jun 10 17:24 @typescript-eslint
lrwxr-xr-x 1 richard staff 67 Jun 10 17:24 esbuild -> ../../../../node_modules/.pnpm/esbuild@0.14.43/node_modules/esbuild
lrwxr-xr-x 1 richard staff 64 Jun 10 17:24 eslint -> ../../../../node_modules/.pnpm/eslint@8.17.0/node_modules/eslint
lrwxr-xr-x 1 richard staff 129 Jun 10 17:24 eslint-config-airbnb-base -> ../../../../node_modules/.pnpm/eslint-config-airbnb-base@15.0.0_3yxiwxzsqipdmy4jwrlv6vgfmy/node_modules/eslint-config-airbnb-base
lrwxr-xr-x 1 richard staff 109 Jun 10 17:24 eslint-config-prettier -> ../../../../node_modules/.pnpm/eslint-config-prettier@8.5.0_eslint@8.17.0/node_modules/eslint-config-prettier
lrwxr-xr-x 1 richard staff 123 Jun 10 17:24 eslint-config-standard -> ../../../../node_modules/.pnpm/eslint-config-standard@17.0.0_zjvxihbqpc3or6hnh25vy3fbci/node_modules/eslint-config-standard
lrwxr-xr-x 1 richard staff 119 Jun 10 17:24 eslint-plugin-import -> ../../../../node_modules/.pnpm/eslint-plugin-import@2.26.0_pv5w3e62ssxduf5aiwxbc3knra/node_modules/eslint-plugin-import
lrwxr-xr-x 1 richard staff 115 Jun 10 17:24 eslint-plugin-jest -> ../../../../node_modules/.pnpm/eslint-plugin-jest@26.5.3_zok5b7ewqm4c2qplh4jsnnnkk4/node_modules/eslint-plugin-jest
lrwxr-xr-x 1 richard staff 102 Jun 10 17:24 eslint-plugin-node -> ../../../../node_modules/.pnpm/eslint-plugin-node@11.1.0_eslint@8.17.0/node_modules/eslint-plugin-node
lrwxr-xr-x 1 richard staff 122 Jun 10 17:24 eslint-plugin-prettier -> ../../../../node_modules/.pnpm/eslint-plugin-prettier@4.0.0_ucegkljdju7q4zmvwxzqoprf3y/node_modules/eslint-plugin-prettier
lrwxr-xr-x 1 richard staff 107 Jun 10 17:24 eslint-plugin-promise -> ../../../../node_modules/.pnpm/eslint-plugin-promise@6.0.0_eslint@8.17.0/node_modules/eslint-plugin-promise
lrwxr-xr-x 1 richard staff 80 Jun 10 17:24 jest -> ../../../../node_modules/.pnpm/jest@28.1.1_@types+node@17.0.41/node_modules/jest
lrwxr-xr-x 1 richard staff 67 Jun 10 17:24 prettier -> ../../../../node_modules/.pnpm/prettier@2.6.2/node_modules/prettier
lrwxr-xr-x 1 richard staff 64 Jun 10 17:24 prisma -> ../../../../node_modules/.pnpm/prisma@3.15.1/node_modules/prisma
lrwxr-xr-x 1 richard staff 93 Jun 10 17:24 ts-jest -> ../../../../node_modules/.pnpm/ts-jest@28.0.4_hhjivpbef6nbltei64cv7t7zz4/node_modules/ts-jest
lrwxr-xr-x 1 richard staff 86 Jun 10 17:24 ts-loader -> ../../../../node_modules/.pnpm/ts-loader@9.3.0_typescript@4.7.3/node_modules/ts-loader
lrwxr-xr-x 1 richard staff 71 Jun 10 17:24 typescript -> ../../../../node_modules/.pnpm/typescript@4.7.3/node_modules/typescript
This seems more like an issue with pnpm
than Prisma
, possibly?
I can reproduce on your project https://github.com/richardwardza/prisma-lambda-layers @richardwardza
and if I follow it
It turned out that my previous suggestion to modify tsconfig.json didn't work. However, the suggestion on this other issue to add the following to schema.prisma did help:
generator client {
provider = "prisma-client-js"
output = "../node_modules/.prisma/client"
}
Also, in my case, I had to change my import to (note, your relative path may vary):
import { PrismaClient } from '../../node_modules/.prisma/client'
Now I can build and run without errors.
Thanks @scottned - adding output = "../node_modules/.prisma/client"
also solves it for me.
Note that this optimally should not be neccessary - so we are still treating this as a bug to fix. But good you found a temporary workaround!
@Jolg42 Here is what you wanna see:
[kasir@kasir client]$ ls -ltrha
total 28K
-rw-r--r-- 1 kasir kasir 317 Jun 15 15:52 index.js
-rw-r--r-- 1 kasir kasir 321 Jun 15 15:52 index-browser.js
drwxr-xr-x 3 kasir kasir 4.0K Jun 15 15:52 ..
-rw-r--r-- 1 kasir kasir 1.2K Jun 15 15:52 index.d.ts
-rw-r--r-- 1 kasir kasir 335 Jun 15 15:52 edge.js
-rw-r--r-- 1 kasir kasir 1.2K Jun 15 15:52 edge.d.ts
drwxr-xr-x 2 kasir kasir 4.0K Jun 15 15:52 .
It is wired though. My result with @richardwardza is different as you see in this comment. It is weird and annoying. What can I do?
Really weird. Now it is gone. I guess I am gonna get crazy after a short time if see such behaviors too much. I used this:
import { PrismaClient } from '@prisma/client';
I have No idea why it resolved. I did nothing basically. But my linux distro is Manjaro this time. maybe Ubuntu is causing this problem.
But now import { Prisma } from '@prisma/client';
does not work
Module '"@prisma/client"' has no exported member 'Prisma'.ts(2305)
Here is what I did:
[kasir@kasir take-report]$ pnpx prisma generate
.../share/pnpm/store/v3/tmp/dlx-27253 | +2 +
Packages are hard linked from the content-addressable store to the virtual store.
Content-addressable store is at: /home/kasir/.local/share/pnpm/store/v3
Virtual store is at: ../.local/share/pnpm/store/v3/tmp/dlx-27253/node_modules/.pnpm
.../share/pnpm/store/v3/tmp/dlx-27253 | Progress: resolved 2, reused 2, downloaded 0, added 2, done
Prisma schema loaded from prisma/schema.prisma
Error: Generator at prisma-dbml-generator could not start:
/bin/sh: line 1: prisma-dbml-generator: command not found
ERROR Command failed with exit code 1: /home/kasir/.local/share/pnpm/store/v3/tmp/dlx-27253/node_modules/.bin/prisma generate
Basically this code works with npm.
Really weird. Now it is gone. I guess I am gonna get crazy after a short time if see such behaviors too much. I used this:
import { PrismaClient } from '@prisma/client';
I have No idea why it resolved. I did nothing basically. But my linux distro is Manjaro this time. maybe Ubuntu is causing this problem.
But now
import { Prisma } from '@prisma/client';
does not workModule '"@prisma/client"' has no exported member 'Prisma'.ts(2305)
Here is what I did:
[kasir@kasir take-report]$ pnpx prisma generate .../share/pnpm/store/v3/tmp/dlx-27253 | +2 + Packages are hard linked from the content-addressable store to the virtual store. Content-addressable store is at: /home/kasir/.local/share/pnpm/store/v3 Virtual store is at: ../.local/share/pnpm/store/v3/tmp/dlx-27253/node_modules/.pnpm .../share/pnpm/store/v3/tmp/dlx-27253 | Progress: resolved 2, reused 2, downloaded 0, added 2, done Prisma schema loaded from prisma/schema.prisma Error: Generator at prisma-dbml-generator could not start: /bin/sh: line 1: prisma-dbml-generator: command not found ERROR Command failed with exit code 1: /home/kasir/.local/share/pnpm/store/v3/tmp/dlx-27253/node_modules/.bin/prisma generate
Basically this code works with npm.
thanks
It turned out that my previous suggestion to modify tsconfig.json didn't work. However, the suggestion on this other issue to add the following to schema.prisma did help:
generator client { provider = "prisma-client-js" output = "../node_modules/.prisma/client" }
Also, in my case, I had to change my import to (note, your relative path may vary):
import { PrismaClient } from '../../node_modules/.prisma/client'
Now I can build and run without errors.
Solved for me, I'm using pnpm. Could we please put a notification on the docs for pnpm users? https://www.prisma.io/docs/concepts/components/prisma-client
Not really, because this should not even be necessary. Can you please open a new issue with a full description and reproduction what is happening for you? Then we can take a look and fix this properly. (Although of course we are happy you found a working temporary workaround that unblocks you.)
generator client {
provider = "prisma-client-js"
output = "../node_modules/.prisma/client"
}
import { PrismaClient } from '../../node_modules/.prisma/client'
didn't solve for me, env:
node v16.0.0
npm 7.20.5
"@prisma/client": "^4.3.0",
"prisma": "^4.2.1",
how to solve?
generator client {
provider = "prisma-client-js"
output = "../node_modules/.prisma/client"
}
import { PrismaClient } from '.prisma/client'
None of the provided solutions worked for me
Also seeing this on:
pnpm@7.11.0
prisma@^4.3.1
with a monorepo setup.
With pnpm, the packages are symlinked to avoid multiple dependency issues as you can see here: https://pnpm.io/symlinked-node-modules-structure
When prisma generates a new client, it creates the generated client structure under root/nodemodules/.pnpm/@prisma/client(some_id)/node_modules/.prisma/client.
If you want to access this globally you could create .npmrc that will be in the root folder of your monorepo and add the following:
strict-peer-dependencies=false
public-hoist-pattern[]=*prisma*
This will make the dependency globally available to all the workspaces in the monorepo.
Encountered this in a yarn (v1.22.18) monorepo where the Prisma schema is in a non-default location. I worked around it by adding a prepare
(post-install) script to the root package.json:
"scripts": {
...,
"db:generate-types": "prisma generate --schema=./common/storage/prisma/schema.prisma",
"prepare": "patch-package && yarn db:generate-types"
},
Still no luck with pnpm, I am about to drop pnpm as a package manager, so many flaws
I'm using pnpm and had luck with specifying a custom location per https://www.prisma.io/docs/concepts/components/prisma-client/working-with-prismaclient/generating-prisma-client#using-a-custom-output-path.
I chose not to generate to node_modules
so @prisma/client
is unavailable for use. Instead I have a package which re-exports everything from the generated client.
packages/prisma/schema.prisma
:
generator client {
provider = "prisma-client-js"
output = "prisma-generated/client"
}
packages/prisma/src/index.ts
:
export * from '../prisma-generated/client';
packages/prisma/package.json
:
...
"name": "@internal/prisma",
...
packages/app/src/index.ts
:
import { PrismaClient } from '@internal/prisma';
With pnpm, the packages are symlinked to avoid multiple dependency issues as you can see here: https://pnpm.io/symlinked-node-modules-structure
When prisma generates a new client, it creates the generated client structure under root/nodemodules/.pnpm/@prisma/client(some_id)/node_modules/.prisma/client.
If you want to access this globally you could create .npmrc that will be in the root folder of your monorepo and add the following:
strict-peer-dependencies=false public-hoist-pattern[]=*prisma*
This will make the dependency globally available to all the workspaces in the monorepo.
This solved my errors when importing generated models from Primsa 🚀
I've been at this for two days now, keep thinking this is somehow solve-able.
I have a turborepo, deployed on vercel, and am trying to use Prisma as a standalone package so I can import it into my two native apps which rely on the said monorepo.
The crazy thing is, in local all is well and good, so there's not a good way to debug this.
apparently restarting TypeScript resolves this... https://stackoverflow.com/questions/69274503/property-does-not-exist-when-i-want-to-use-model-added-in-prisma-schema
I am running into this issue during our CI w/ GitHub actions
generator client {
provider = "prisma-client-js"
output = "../node_modules/.prisma/client"
}
Fixed for me.
huge issues with combo: turborepo, pnpm and prisma. tried it all, nothing works well. This does not reliably help: https://turbo.build/repo/docs/handbook/tools/prisma
huge issues with combo: turborepo, pnpm and prisma. tried it all, nothing works well. This does not reliably help: https://turbo.build/repo/docs/handbook/tools/prisma
There are issues but if this can help, I managed to make it work quite good with the following stack:
prisma db seed
work with Node 18 in ESM modepreserveSymlinks
must not be set to true
in tsconfig.json
otherwise it breaks everythingoutput
in schema.prisma
otherwise it breaks the prisma/client/edge
(if using edge runtime).npmrc
:
public-hoist-pattern[]=@prisma/*
public-hoist-pattern[]=prisma
Everything else is done according to the turbo documentation.
Faced the same issue in an Nx monorepo using pnpm v8.1.0, node v16.17.1, windows.
Solved by having a npx prisma generate
target called "prisma-generate"
and for each app and library where @prisma/client
is used, putting "dependsOn": [ "prisma-generate" ]
within the "build"
target. The hint here was it was only failing for my GitHub CI where the library was built in isolation.
Tagging @pnxdxt in case above is useful
install node 16 will sovle, prisma 4 doesn't support certain version of node.
For me, it was due to VSCode apparently "caching" the directories. I had to Reload Window
and then everything was imported correctly without errors.
@scottned @lantos1618 @phifa @ralcorta @andrewmclagan @timmeade @irg1008
Are you by any chance using preserveSymlinks
?
I confirmed that this is causing issues with Prisma Client and pnpm
, setting it to false
prevents type issues.
Have you tried to restart VSCode or the TS Server? Some users have reported that after being generate, VSCode did not pick up the new generated types.
Have you tried manually running prisma generate
, did that change anything?
Some users have reported that Prisma Client auto-generate does not work well on pnpm
.
There are many issues interleaved, and so far we know my three mentions just above are things we need to fix or document.
Did any of these help? If not, could you please provide us with a small reproduction? We are not able to reproduce the issues mentioned in the comments, so we need your help :pray: I'd appreciate if you could submit us some code.
It is probably the first point. PreserveSymLinks sounds like the one to do the job but what I am doing now is just using this
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
previewFeatures = ["jsonProtocol"]
output = "../src/generated/prisma/client"
}
and adding src/generated
to .gitignore
This way if someone clones the repo it will work for them without them needing to change settings if they use pnpm
For me the problem happened after running pnpx prisma generate
, what helped was to update prisma to the latest version in project deps, run pnpm prisma generate
(not pnpx) and restart ts service. Hope this helps someone.
I deployed on vercel and have the same issue. How to fix it please?
@nixjs Your error is slightly different, it says that SocialProviderLogin
cannot be imported. Does this also happen with PrismaClient
?
I deployed on vercel and have the same issue. How to fix it please?
I resolved
I have strictly followed this tutorial and this is the error I get:
Unable to interop `export * from "@prisma/client"` in /Users/me/project-root/packages/database/index.ts, this may lose module exports. Please export "@prisma/client" as ESM or use named exports instead, e.g. `export { A, B } from "@prisma/client"`
I have also tried the fixes proposed above without success.
The issue is one year old but still getting impacted people. Monorepo is not a edge.
EDIT
VSCode tries to import from project-root/node_modules/.pnpm/@prisma+client@5.0.0_prisma@5.0.0/node_modules/@prisma/client
while the generated path is project-root/node_modules/.pnpm/@prisma+client@5.0.0_prisma@5.0.0/@prisma/client
(without node_modules
)
@eakl The error looks different that the one mentioned in the original post. Could you please open a new issue? Also, have you run pnpm prisma generate
? (auto-generate is currently dysfunctional on pnpm
).
Run pnpm prisma generate
to create the .prisma/client
folder that @prisma/client
attempts to import from.
it works for me,
i also using:
pnpm v8
nuxt 3.6.5
prisma 5. and read the update. i already upgrade to 5.1.1
pnpm upgrade prisma@5 @prisma/client@5
IDE VSCode
references
const { PrismaClient } = require('@prisma/client') const prisma = new PrismaClient()
// use prisma
in your application to read and write data in your DB
npx prisma generate
I have strictly followed this tutorial and this is the error I get:
Unable to interop `export * from "@prisma/client"` in /Users/me/project-root/packages/database/index.ts, this may lose module exports. Please export "@prisma/client" as ESM or use named exports instead, e.g. `export { A, B } from "@prisma/client"`
I have also tried the fixes proposed above without success.
The issue is one year old but still getting impacted people. Monorepo is not a edge.
EDIT
VSCode tries to import from
project-root/node_modules/.pnpm/@prisma+client@5.0.0_prisma@5.0.0/node_modules/@prisma/client
while the generated path isproject-root/node_modules/.pnpm/@prisma+client@5.0.0_prisma@5.0.0/@prisma/client
(withoutnode_modules
)
Did you ever manage to solve this. I too am trying to get a mono-repo up and run where i am able to import prisma types and enums on the front end
I have strictly followed this tutorial and this is the error I get:
Unable to interop `export * from "@prisma/client"` in /Users/me/project-root/packages/database/index.ts, this may lose module exports. Please export "@prisma/client" as ESM or use named exports instead, e.g. `export { A, B } from "@prisma/client"`
I have also tried the fixes proposed above without success. The issue is one year old but still getting impacted people. Monorepo is not a edge. EDIT VSCode tries to import from
project-root/node_modules/.pnpm/@prisma+client@5.0.0_prisma@5.0.0/node_modules/@prisma/client
while the generated path isproject-root/node_modules/.pnpm/@prisma+client@5.0.0_prisma@5.0.0/@prisma/client
(withoutnode_modules
)Did you ever manage to solve this. I too am trying to get a mono-repo up and run where i am able to import prisma types and enums on the front end
For some extra details:
The frontend uses VITE
This is the VITE server runtime error:
Unable to interop `export * from "@prisma/client"` in /home/[user]/Documents/[project]/packages/db/index.ts, this may lose module exports. Please export "@prisma/client" as ESM or use named exports instead, e.g. `export { A, B } from "@prisma/client"`
This is the Browser console error: Uncaught SyntaxError: ambiguous indirect export: UserType
This is the line when i view the transpiled source the browser is trying to run import { UserType } from "/@fs/home/[user]/Documents/[project]/packages/db/index.ts";
I have strictly followed this tutorial and this is the error I get:
Unable to interop `export * from "@prisma/client"` in /Users/me/project-root/packages/database/index.ts, this may lose module exports. Please export "@prisma/client" as ESM or use named exports instead, e.g. `export { A, B } from "@prisma/client"`
I have also tried the fixes proposed above without success.
The issue is one year old but still getting impacted people. Monorepo is not a edge.
EDIT
VSCode tries to import from
project-root/node_modules/.pnpm/@prisma+client@5.0.0_prisma@5.0.0/node_modules/@prisma/client
while the generated path isproject-root/node_modules/.pnpm/@prisma+client@5.0.0_prisma@5.0.0/@prisma/client
(withoutnode_modules
)
@eakl
If all you want to do is use the enums on the frontend you can create a new in the database package like /Users/me/project-root/packages/database/index.ts
with contents:
export {$Enums} from '@prisma/client';
and be sure to change all front-end imports to use this new file
here is example
import {$Enum} from "@database/prisma/client";
function checkUserType(type: $Enum.UserType){
switch(type){
case $Enum.UserType.ADMIN:
console.log("You are an admin");
break;
case $Enum.UserType.CUSTOMER:
console.log("You are a customer");
break;
}
}
for the model types i suggest using something like zod-prisma-types as it also exports lots of other useful type like relational type and whats not
and have it generate types in a folder like /Users/me/project-root/packages/database/index.ts
(make sure its git ignored btw)
and on the front-end import all model types from there. This will require installing zod if you don't already use it but i highly recommend it
example:
import type {User} from "@database/prisma/generated"
function takeUser(user: User){
return user;
}
Bug description
I tried to use pnpm in my proj but it seems it does not work
I see this two issues too but none of them helped:
How to reproduce
pnpm install
pnpm prisma generate
src/shared/modules/prisma/prisma.service.ts
Expected behavior
No error just import
PrismaClient
Prisma information
See repo
Environment & setup
Prisma Version