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

Generator output client leads to Error: ENOENT: no such file or directory, open '.../node_modules/@prisma/client/schema.prisma' #12295

Closed
xygengcn opened this issue Mar 12, 2022 · 10 comments
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. tech/typescript Issue for tech TypeScript. topic: ENOENT schema.prisma Issues about "Error: ENOENT: no such file or directory, open '.../schema.prisma'" topic: output=client
Milestone

Comments

@xygengcn
Copy link

xygengcn commented Mar 12, 2022

Bug description

If you set the value of output, the following things will happen. If you do not set, the program is normal。

please help

How to reproduce

i can set output in new version

Expected behavior

Error: ENOENT: no such file or directory, open '/Users/xxx/Program/prisma/node_modules/@prisma/client/schema.prisma'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at new LibraryEngine (/Users/xxx/Program/prisma/prisma/client/runtime/index.js:35468:41)
    at PrismaClient.getEngine (/Users/xxx/Program/prisma/prisma/client/runtime/index.js:40266:16)
    at new PrismaClient (/Users/xxx/Program/prisma/prisma/client/runtime/index.js:40241:29)
    at Object.<anonymous> (/Users/xxx/Program/prisma/src/models.ts:2:16)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Module.m._compile (/Users/xxx/Program/prisma/node_modules/ts-node/src/index.ts:1459:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/xxx/Program/prisma/node_modules/ts-node/src/index.ts:1462:12) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/Users/xxx/Program/prisma/node_modules/@prisma/client/schema.prisma',
  clientVersion: '3.11.0-integration-mobc-fix.1'
}

Prisma information

generator client {
  provider = "prisma-client-js"
  output   = "client". // If not, it is normal
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

Environment & setup

  • OS:
  • Mac
  • Database:
  • Mysql
  • Node.js version:
  • 16.8.0

Prisma Version

prisma                  : 3.11.0-integration-mobc-fix.1
@prisma/client          : 3.11.0-integration-mobc-fix.1
Current platform        : darwin
Query Engine (Node-API) : libquery-engine ca9fb922c8fd66aa105fe549629891efc4219ca3 (at node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine        : migration-engine-cli ca9fb922c8fd66aa105fe549629891efc4219ca3 (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine    : introspection-core ca9fb922c8fd66aa105fe549629891efc4219ca3 (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary           : prisma-fmt ca9fb922c8fd66aa105fe549629891efc4219ca3 (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash    : test-mobc-fix-ca9fb922c8fd66aa105fe549629891efc4219ca3
Studio                  : 0.458.0
@xygengcn xygengcn added the kind/bug A reported bug. label Mar 12, 2022
@janpio janpio added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. team/client Issue for team Client. labels Mar 12, 2022
@janpio
Copy link
Member

janpio commented Mar 12, 2022

Do I understand correctly that setting an output property for your generator block breaks something?
Where exactly do you get this error message?
I see you are using a dev version of 3.11.0. Does this also happen with 3.10.0?

@xygengcn xygengcn reopened this Mar 13, 2022
@xygengcn
Copy link
Author

xygengcn commented Mar 13, 2022

@janpio yes,3.10.0、3.11.0、3.9.0 also happen,this error message will appear after i run script npm run dev

prisma generate and prisma migrate normally

@janpio
Copy link
Member

janpio commented Mar 13, 2022

This is unexpected, as this functionality is probably used by many people and no one has reported this before.

Does this also happen when you create a new project with npx prisma init? If so, please put it on GitHub and post the link so we can reproduce.

@xygengcn
Copy link
Author

This is unexpected, as this functionality is probably used by many people and no one has reported this before.

Does this also happen when you create a new project with npx prisma init? If so, please put it on GitHub and post the link so we can reproduce.

here reproduce link https://github.com/xygengcn/prisma-demo, thanks

@janpio janpio added bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Mar 13, 2022
@janpio
Copy link
Member

janpio commented Mar 13, 2022

I can confirm the problem:

C:\Users\Jan\Documents\throwaway\12295>npm install

added 21 packages, and audited 22 packages in 17s

found 0 vulnerabilities

C:\Users\Jan\Documents\throwaway\12295>npm run dev

> dev
> ts-node ./script.ts

Error: ENOENT: no such file or directory, open 'C:\Users\Jan\Documents\throwaway\12295\node_modules\.prisma\client\schema.prisma'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at new LibraryEngine (C:\Users\Jan\Documents\throwaway\12295\prisma\client\runtime\index.js:36082:40)
    at PrismaClient.getEngine (C:\Users\Jan\Documents\throwaway\12295\prisma\client\runtime\index.js:40406:16)
    at new PrismaClient (C:\Users\Jan\Documents\throwaway\12295\prisma\client\runtime\index.js:40377:29)
    at Object.<anonymous> (C:\Users\Jan\Documents\throwaway\12295\script.ts:3:16)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Module.m._compile (C:\Users\Jan\Documents\throwaway\12295\node_modules\ts-node\src\index.ts:1459:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Object.require.extensions.<computed> [as .ts] (C:\Users\Jan\Documents\throwaway\12295\node_modules\ts-node\src\index.ts:1462:12) {
  errno: -4058,
  syscall: 'open',
  code: 'ENOENT',
  path: 'C:\\Users\\Jan\\Documents\\throwaway\\12295\\node_modules\\.prisma\\client\\schema.prisma',
  clientVersion: '3.9.1'
}

(Also with 3.10.0)

@xygengcn
Copy link
Author

I can confirm the problem:


C:\Users\Jan\Documents\throwaway\12295>npm install



added 21 packages, and audited 22 packages in 17s



found 0 vulnerabilities



C:\Users\Jan\Documents\throwaway\12295>npm run dev



> dev

> ts-node ./script.ts



Error: ENOENT: no such file or directory, open 'C:\Users\Jan\Documents\throwaway\12295\node_modules\.prisma\client\schema.prisma'

    at Object.openSync (node:fs:585:3)

    at Object.readFileSync (node:fs:453:35)

    at new LibraryEngine (C:\Users\Jan\Documents\throwaway\12295\prisma\client\runtime\index.js:36082:40)

    at PrismaClient.getEngine (C:\Users\Jan\Documents\throwaway\12295\prisma\client\runtime\index.js:40406:16)

    at new PrismaClient (C:\Users\Jan\Documents\throwaway\12295\prisma\client\runtime\index.js:40377:29)

    at Object.<anonymous> (C:\Users\Jan\Documents\throwaway\12295\script.ts:3:16)

    at Module._compile (node:internal/modules/cjs/loader:1103:14)

    at Module.m._compile (C:\Users\Jan\Documents\throwaway\12295\node_modules\ts-node\src\index.ts:1459:23)

    at Module._extensions..js (node:internal/modules/cjs/loader:1155:10)

    at Object.require.extensions.<computed> [as .ts] (C:\Users\Jan\Documents\throwaway\12295\node_modules\ts-node\src\index.ts:1462:12) {

  errno: -4058,

  syscall: 'open',

  code: 'ENOENT',

  path: 'C:\\Users\\Jan\\Documents\\throwaway\\12295\\node_modules\\.prisma\\client\\schema.prisma',

  clientVersion: '3.9.1'

}

(Also with 3.10.0)

yes,also 3.11.0 dev

@janpio
Copy link
Member

janpio commented Mar 13, 2022

This seems to be a special case when the output value is exactly client. When I set any other value (e.g. foo) and update the import in my script.ts to import { PrismaClient } from './prisma/foo' to reflect that, everything works as expected.

Can you confirm?

@xygengcn
Copy link
Author

xygengcn commented Mar 13, 2022

Yeath! Using foo instead of client,everything works as expected. @janpio

@janpio janpio changed the title if schema output is not null, then no such file or directory, open ”.../schema.prisma“ Generator output client leads to Error: ENOENT: no such file or directory, open '.../node_modules/@prisma/client/schema.prisma' Mar 13, 2022
@janpio
Copy link
Member

janpio commented Mar 13, 2022

Thanks. We will treat this as a bug, I updated the issue title to make it easier to understand.

@janpio janpio added topic: ENOENT schema.prisma Issues about "Error: ENOENT: no such file or directory, open '.../schema.prisma'" tech/typescript Issue for tech TypeScript. labels Apr 27, 2022
@millsp millsp assigned millsp and unassigned millsp Sep 13, 2022
@millsp millsp added this to the 4.14.0 milestone Apr 25, 2023
@millsp millsp self-assigned this Apr 25, 2023
@millsp
Copy link
Member

millsp commented Apr 25, 2023

Closing as already fixed in latest releases.

@millsp millsp closed this as completed Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. tech/typescript Issue for tech TypeScript. topic: ENOENT schema.prisma Issues about "Error: ENOENT: no such file or directory, open '.../schema.prisma'" topic: output=client
Projects
None yet
Development

No branches or pull requests

4 participants
@janpio @millsp @xygengcn and others