oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.31k stars 2.69k forks source link

bun install breaks Prisma #4828

Open jesserizzo opened 1 year ago

jesserizzo commented 1 year ago

What version of Bun is running?

1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983

What platform is your computer?

Linux 5.15.116.1-1.cm2 x86_64 unknown

What steps can reproduce the bug?

In a currently working Node JS app using Prisma, running in Azure App Service

What is the expected behavior?

The app should start successfully

What do you see instead?

The app fails to start with the following error message:

TypeError: Cannot read properties of undefined (reading 'enumTypes')
     at Wr.getEnumMap (/home/site/wwwroot/build-server/node_modules/@prisma/client/runtime/library.js:31:4185)
     at new Wr (/home/site/wwwroot/build-server/node_modules/@prisma/client/runtime/library.js:31:1858)
     at new We (/home/site/wwwroot/build-server/node_modules/@prisma/client/runtime/library.js:31:4822)
     at new t (/home/site/wwwroot/build-server/node_modules/@prisma/client/runtime/library.js:177:4706)
     at Object.<anonymous> (/home/site/wwwroot/build-server/server/services/prisma.service.js:8:14)
     at Module._compile (node:internal/modules/cjs/loader:1198:14)
     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
     at Module.load (node:internal/modules/cjs/loader:1076:32)
     at Function.Module._load (node:internal/modules/cjs/loader:911:12)
     at Module.require (node:internal/modules/cjs/loader:1100:19) {
   clientVersion: '4.12.0'

The possibly relevant contents of that file

return`Prisma Client could not locate the Query Engine for runtime "${t}".`}function ze(e){let{searchedLocations:t}=e;return`The following locations have been searched:
${[...new Set(t)].map(i=>`  ${i}`).join(`
`)}`}function Ws(e){let{runtimeBinaryTarget:t}=e;return`${He(e)}

This happened because \`binaryTargets\` have been pinned, but the actual deployment also required "${t}".
${Zr(e)}

${ze(e)}`}function Xr(e){return`We would appreciate if you could take the time to share some information with us.
Please help us by answering a few questions: https://pris.ly/${e}`}function Hs(e){let{queryEngineName:t}=e;return`${He(e)}

This is likely caused by a bundler that has not copied "${t}" next to the resulting bundle.
Ensure that "${t}" has been copied next to the bundle or in "${e.expectedLocation}".

${Xr("engine-not-found-bundler-investigation")}

${ze(e)}`}function zs(e){let{runtimeBinaryTarget:t,generatorBinaryTargets:r}=e,n=r.find(i=>i.native);return`${He(e)}

This happened because Prisma Client was generated for "${n?.value??"unknown"}", but the actual deployment required "${t}".
${Zr(e)}

${ze(e)}`}function Ys(e){let{queryEngineName:t}=e;return`${He(e)}

This is likely caused by tooling that has not copied "${t}" to the deployment folder.
Ensure that you ran \`prisma generate\` and that "${t}" has been copied to "${e.expectedLocation}".

Additional information

Prisma automatically generates a client when you install the package, using ~magic~ post install hooks (?) based on what's in your Prisma.schema file. https://www.prisma.io/docs/concepts/components/prisma-client/working-with-prismaclient/generating-prisma-client#generating-prisma-client-in-the-postinstall-hook-of-prismaclient

quyctd commented 1 year ago

Have you tried to run bun run prisma generate after bun install? I'm not sure about Node.js app, but in my case - a next.js app, running bun run prisma generate after bun install and the errors gone.

jesserizzo commented 1 year ago

Have you tried to run bun run prisma generate after bun install? I'm not sure about Node.js app, but in my case - a next.js app, running bun run prisma generate after bun install and the errors gone.

I didn't try that. Even if that does work, I believe there is still a bug here. Bun is intended to be a drop in replacement, and running prisma generate after installing the package is not a step that's required when installing it with yarn or npm.

sacummings91 commented 1 year ago

I am running into a similar error. It seems like bun fails to execute the postInstall script or something because I just don't have a .prisma folder at all in node_modules

akirarika commented 1 year ago

@sacummings91 Is my issue similar to yours? #5165

sacummings91 commented 1 year ago

@akirarika I don't think so, but I'm sure it's all generally related to the same problem.

jesserizzo commented 1 year ago

Just checked, I'm also missing the .prisma folder in node_modules, which as @sacummings91 mentioned, probably means it just isn't running the post-install hook at all. Also, I'm running this in Docker, forgot to mention that before.