Skip to main content

Installation

This guide covers how to install Prisma ORM in your project using your preferred package manager.

System requirements

Before installing Prisma, ensure your system meets these requirements:
  • Node.js: Version 20.19+, 22.12+, or 24.0+
  • TypeScript: Version 5.4.0 or higher (optional, but recommended)
  • Package manager: npm, yarn, pnpm, or bun
Prisma ORM works with both JavaScript and TypeScript, but TypeScript is recommended for the best developer experience with full type safety.

Installation methods

Prisma consists of two main packages:
  1. prisma - The Prisma CLI for database migrations, schema management, and client generation
  2. @prisma/client - The Prisma Client runtime for querying your database
You’ll typically install the CLI as a development dependency and the client as a regular dependency.

Install with npm

npm is the default package manager that comes with Node.js.

Install Prisma CLI

npm install prisma --save-dev

Install Prisma Client

npm install @prisma/client

Install both packages

npm install prisma --save-dev
npm install @prisma/client

Install with Yarn

Yarn is a popular alternative package manager with improved performance and security.

Install Prisma CLI

yarn add prisma --dev

Install Prisma Client

yarn add @prisma/client

Install both packages

yarn add prisma --dev
yarn add @prisma/client

Install with pnpm

pnpm is a fast, disk-efficient package manager that’s gaining popularity, especially in monorepos.
Prisma itself is developed using pnpm. The Prisma repository requires pnpm version 10.15 or higher (but less than version 11).

Install Prisma CLI

pnpm add -D prisma

Install Prisma Client

pnpm add @prisma/client

Install both packages

pnpm add -D prisma
pnpm add @prisma/client

Install with Bun

Bun is an all-in-one JavaScript runtime and toolkit with a built-in package manager.

Install Prisma CLI

bun add -D prisma

Install Prisma Client

bun add @prisma/client

Install both packages

bun add -D prisma
bun add @prisma/client
Bun automatically loads .env files, so you don’t need to import dotenv/config in your Prisma configuration when using Bun.

Install database adapters

Prisma uses driver adapters to connect to databases. Install the appropriate adapter for your database:

PostgreSQL

npm install @prisma/adapter-pg pg

Neon (Serverless PostgreSQL)

npm install @prisma/adapter-neon @neondatabase/serverless

PlanetScale (Serverless MySQL)

npm install @prisma/adapter-planetscale @planetscale/database

SQLite

npm install @prisma/adapter-better-sqlite3 better-sqlite3

LibSQL (Turso)

npm install @prisma/adapter-libsql @libsql/client

Cloudflare D1

npm install @prisma/adapter-d1

MySQL/MariaDB

npm install @prisma/adapter-mysql mysql2

SQL Server

npm install @prisma/adapter-mssql mssql

Verify installation

After installation, verify that Prisma is installed correctly:
npx prisma --version
You should see output showing the Prisma version, like:
prisma                  : 7.5.0
@prisma/client          : 7.5.0

Next steps

Now that Prisma is installed, you’re ready to start using it:
1

Create your schema

Set up a prisma/schema.prisma file to define your data models.
2

Configure connection

Create a prisma.config.ts file with your database connection details.
3

Generate Prisma Client

Run npx prisma generate to create your type-safe database client.
4

Start querying

Import and use Prisma Client in your application.

Follow the Quickstart

Step-by-step guide to build your first Prisma application

Read the Schema Reference

Learn about all the schema syntax and options

Prisma configuration file

Prisma 7 uses a TypeScript configuration file for database connections and settings. Create a prisma.config.ts file:
prisma.config.ts
import { defineConfig, env } from 'prisma/config'

type Env = {
  DATABASE_URL: string
}

export default defineConfig({
  datasource: {
    url: env<Env>('DATABASE_URL'),
  },
})
The env function provides type-safe access to environment variables and throws an error if required variables are missing at runtime.
Unlike Prisma 6 and earlier, Prisma 7 does not automatically load .env files. Use packages like dotenv or @dotenvx/dotenvx to load environment variables, or use Node.js built-in --env-file flag.

Loading environment variables

To load environment variables from a .env file:

Using dotenv

Install dotenv:
npm install dotenv
Import it in your config:
prisma.config.ts
import 'dotenv/config'
import { defineConfig, env } from 'prisma/config'

export default defineConfig({
  datasource: {
    url: env('DATABASE_URL'),
  },
})

Using Node.js —env-file flag

Node.js 20.6+ supports loading environment variables directly:
node --env-file=.env index.js
Or with tsx:
tsx --env-file=.env index.ts

Using Bun

Bun automatically loads .env files, so no additional configuration is needed.

Updating Prisma

To update Prisma to the latest version:
npm install prisma@latest --save-dev
npm install @prisma/client@latest
Always keep both prisma and @prisma/client at the same version to avoid compatibility issues.

Troubleshooting

Version mismatch

If you encounter errors about version mismatches, ensure both packages are at the same version:
npx prisma --version
Both should show the same version number.

TypeScript errors

If you see TypeScript errors after installation, ensure you have TypeScript 5.4.0 or higher:
npx tsc --version

Missing native dependencies

Some database adapters require native dependencies. For example, better-sqlite3 requires build tools. On error, follow the package’s installation instructions for your platform.