Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion content/200-orm/400-tools/05-prisma-cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,15 @@ pnpm dlx prisma
### Bun

```
bunx prisma
bunx --bun prisma
```

:::note

The `--bun` flag ensures Prisma runs with the Bun runtime. Without it, Prisma falls back to Node.js due to the `#!/usr/bin/env node` shebang in the CLI.

:::

## Synopsis

The `prisma` command can be called from command line once installed. When called without arguments, it will display its command usage and help document:
Expand Down
24 changes: 18 additions & 6 deletions content/200-orm/500-reference/325-prisma-config-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,13 @@ tsx --env-file=.env ./prisma/seed.ts

#### Using Bun

For Bun, `.env` files are automatically loaded without additional configuration.
For Bun, `.env` files are automatically loaded without additional configuration. The `import 'dotenv/config'` line that `prisma init` generates is not needed when using Bun and can be safely removed from your `prisma.config.ts` file.

:::note

When running Prisma CLI commands with Bun, use the `--bun` flag (e.g., `bunx --bun prisma init`) to ensure Prisma uses the Bun runtime instead of falling back to Node.js.

:::

#### Type-safe environment variables

Expand Down Expand Up @@ -738,29 +744,35 @@ pnpm prisma validate
# → Still finds prisma.config.ts and resolves schema correctly
```

### Behavior with `npm exec prisma` or `bun prisma`
### Behavior with `npx prisma` or `bunx --bun prisma`

When running via `npm exec prisma` or `bun prisma`, the CLI only detects the config file if the command is run from the **project root** (where `package.json` declares Prisma).
When running via `npx prisma` or `bunx --bun prisma`, the CLI only detects the config file if the command is run from the **project root** (where `package.json` declares Prisma).

:::note

The `--bun` flag is required when using Bun to ensure Prisma runs with the Bun runtime. Without it, Prisma falls back to Node.js due to the `#!/usr/bin/env node` shebang in the CLI.

:::

Example run from the project root:

```bash
npm exec prisma validate
npx prisma validate
# → Works as expected
```

Run from a subdirectory (fails):

```bash
cd src
npm exec prisma validate
npx prisma validate
# → Error: Could not find Prisma Schema...
```

To fix this, you can use the `--config` flag:

```bash
npm exec prisma -- --config ../prisma.config.ts validate
npx prisma validate --config ../prisma.config.ts
```

### Global Prisma installations
Expand Down
15 changes: 13 additions & 2 deletions content/800-guides/370-bun.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,15 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst
Initialize Prisma ORM with Prisma Postgres in your project:

```terminal
bun prisma init --db
bunx --bun prisma init --db
```

:::note

The `--bun` flag is required to ensure Prisma runs with the Bun runtime. Without it, Prisma falls back to Node.js due to the `#!/usr/bin/env node` shebang in the CLI.

:::

:::info

You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Bun Project"
Expand Down Expand Up @@ -202,7 +208,6 @@ main()
Add the following content to the file:

```typescript file=prisma.config.ts
import 'dotenv/config'
import { defineConfig, env } from 'prisma/config';

export default defineConfig({
Expand All @@ -219,6 +224,12 @@ export default defineConfig({
});
```

:::note

Unlike Node.js, Bun automatically loads `.env` files, so the `import 'dotenv/config'` line is not needed. If you see this import in your generated `prisma.config.ts`, you can safely remove it.

:::

Run the seed script to populate your database:

```terminal
Expand Down
10 changes: 5 additions & 5 deletions content/800-guides/440-elysia.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ If you are using a different database provider (MySQL, SQL Server, SQLite), inst
Once installed, initialize Prisma in your project:

```terminal
bunx prisma init --db --output ../src/generated/prisma
bunx --bun prisma init --db --output ../src/generated/prisma
```

:::info
Expand Down Expand Up @@ -111,8 +111,8 @@ This matches the Prisma Elysia example: it generates Prisma Client to `src/gener
Run the following commands to create the database tables and generate the Prisma Client:

```terminal
bunx prisma migrate dev --name init
bunx prisma generate
bunx --bun prisma migrate dev --name init
bunx --bun prisma generate
```

### 2.4. Seed the database
Expand Down Expand Up @@ -163,13 +163,13 @@ main()
Run the seed script:

```terminal
bunx prisma db seed
bunx --bun prisma db seed
```

And open Prisma Studio to inspect your data:

```terminal
bunx prisma studio
bunx --bun prisma studio
```

## 3. Integrate Prisma into Elysia
Expand Down
Loading