Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to start nestjs-prisma cannot find module nx-recipes/nestjs-prisma/node_modules/@prisma/client/one #91

Open
GestHairHome opened this issue Jul 11, 2024 · 1 comment

Comments

@GestHairHome
Copy link

After cloning and instal, I ran the following command with the result:
gesthairhome@mbp-de-patrick nestjs-prisma % cp .env.example .env
gesthairhome@mbp-de-patrick nestjs-prisma % nx run-many -t migrate

✔  nx run prisma-schema-two:migrate (2s)
✔  nx run prisma-schema-one:migrate (2s)

—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

NX Successfully ran target migrate for 2 projects (3s)

gesthairhome@mbp-de-patrick nestjs-prisma % nx serve api

nx run api:serve:development

chunk (runtime: main) main.js (main) 23.5 KiB [entry] [rendered]
webpack compiled successfully (43048f463d3f7801)
Debugger listening on ws://localhost:9229/e3c18e9b-1bc0-40ce-b1d5-76f419c3029c
Debugger listening on ws://localhost:9229/e3c18e9b-1bc0-40ce-b1d5-76f419c3029c
For help, see: https://nodejs.org/en/docs/inspector

Error: Cannot find module '/Users/gesthairhome/Applis/nx-recipes/nestjs-prisma/node_modules/@prisma/client/one'
at createEsmNotFoundErr (node:internal/modules/cjs/loader:1181:15)
at finalizeEsmResolution (node:internal/modules/cjs/loader:1169:15)
at resolveExports (node:internal/modules/cjs/loader:591:14)
at Function.Module._findPath (node:internal/modules/cjs/loader:668:31)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1130:27)
at Function.Module._load (node:internal/modules/cjs/loader:985:27)
at Function.Module.load (/Users/gesthairhome/Applis/nx-recipes/nestjs-prisma/node_modules/.pnpm/@nx[email protected]@types[email protected][email protected][email protected]/node_modules/@nx/js/src/executors/node/node-with-require-overrides.js:18:31)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Array.Object.defineProperty.value (/Users/gesthairhome/Applis/nx-recipes/nestjs-prisma/dist/apps/api/webpack:/external commonjs "@prisma/client/one":1:1)

NX Process exited with code 1, waiting for changes to restart...

I have check directory '/Users/gesthairhome/Applis/nx-recipes/nestjs-prisma/node_modules/@prisma/client/one' exist

@maiksfd
Copy link

maiksfd commented Aug 24, 2024

I have the same problem.

If you change the output path in your schema ...

generator client { provider = "prisma-client-js" output = "../../../node_modules/.prisma/client/one" }

and adjust the import for the client ...

import { PrismaClient } from '.prisma/client/one';

... it works. Seems like the files have to be in "node_modules/.prisma/...". Otherwise it can not be imported in the dist/apps//main.js:

module.exports = require("@prisma/client/one"); // Won't work

I do not know if that is an optimal solution :( I would still like to use "@prisma/..." for generation and import.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants