oven-sh / bun

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

error: FileNotFound reading "node:tty" when using prisma after bundling #5194

Open rhea-so opened 1 year ago

rhea-so commented 1 year ago

What version of Bun is running?

1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983

What platform is your computer?

Darwin 22.2.0 arm64 arm

What steps can reproduce the bug?

  1. setup prisma, bun (refer to https://bun.sh/guides/ecosystem/prisma)
bun init
bun add prisma
bunx prisma init --datasource-provider sqlite
bunx prisma migrate dev --name init
  1. add call setTimeout code
import { PrismaClient } from "@prisma/client"; // https://bun.sh/guides/ecosystem/prisma

new PrismaClient();

// ▼ here
setTimeout(() => {
  console.log("Hello, World!");
}, 1000);
  1. bun compile and run
bun build --compile src/index.ts --outfile=dist  
./dist

Note
Reproduce repository


The weird thing is..

There is no problem when running it as a bun run.

What is the expected behavior?

스크린샷 2023-09-13 10 41 16

What do you see instead?

스크린샷 2023-09-13 10 40 50

Additional information

No response

Electroid commented 1 year ago

If you want to build for node or bun, you'll need to specify bun build --target=bun. Otherwise, this will target browsers.