Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
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
14 changes: 7 additions & 7 deletions apps/docs/content/docs/(index)/prisma-orm/from-scratch.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: From scratch
description: Set up Prisma ORM with PostgreSQL by hand, with one config file, one contract, and one index.ts.
url: /prisma-orm/from-scratch
metaTitle: Set up Prisma ORM from scratch
metaDescription: 'Add Prisma ORM 8 to an empty Node.js project without a template: install two packages, write prisma.config.ts and a contract, create the table, query it from one index.ts, and apply a migration.'
metaDescription: 'Add Prisma ORM 8 to an empty Node.js project without a template: install the packages, write prisma.config.ts and a contract, create the table, query it from one index.ts, and apply a migration.'
---

By the end of this page you have a project with a `prisma.config.ts`, a `prisma/contract.prisma` holding one `User` model, and a single `index.ts` that writes, updates, and reads rows in PostgreSQL through Prisma ORM 8, plus a migration you planned and applied. No template generates anything: you create every file yourself and see what each one is for.
Expand Down Expand Up @@ -36,18 +36,18 @@ npm init -y
npm pkg set type=module
```

Install the runtime library, the command-line tool, and the tooling to run a TypeScript file:
Install the runtime library, the packages it is built from, the command-line tool, and the tooling to run a TypeScript file:

```npm
npm install @prisma/orm-postgres pg dotenv
npm install --save-dev prisma tsx typescript @types/pg
npm install @prisma/orm-postgres @prisma/orm-framework @prisma/orm-family-sql @prisma/orm-target-postgres @prisma/orm-toolchain pg @types/pg temporal-polyfill dotenv
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
npm install --save-dev prisma tsx typescript
```

`@prisma/orm-postgres` is the library your code imports, and `prisma` is the command-line tool. `pg` is the PostgreSQL driver, a peer dependency of `@prisma/orm-postgres`, and `@types/pg` gives TypeScript its types. `dotenv` loads `.env`, `tsx` runs `index.ts` without a build step, and `typescript` 5.9 or newer is a peer dependency of `@prisma/orm-postgres`.
`@prisma/orm-postgres` is the library your code imports, and `prisma` is the command-line tool. `@prisma/orm-postgres` is built from four platform packages: `@prisma/orm-framework`, `@prisma/orm-family-sql`, `@prisma/orm-target-postgres` and `@prisma/orm-toolchain`. Your code never imports them. `@prisma/orm-postgres` lists them as peer dependencies, packages it expects your app to install, so your app has exactly one copy of each. Because your app lists each one, the package manager installs one copy of each, which the library and every extension share. Two copies do not work together, so list them whichever package manager you use. [What your package.json lists](/orm/supported-databases#what-your-packagejson-lists) explains it in full.

`temporal-polyfill` is a peer dependency of `@prisma/orm-postgres` too. It adds `Temporal`, the newer JavaScript date and time API, to runtimes such as Node.js 24 that do not have it built in. npm installs it for you, but with Yarn you add it yourself.
`pg` is the PostgreSQL driver, another peer dependency of `@prisma/orm-postgres`, and `@types/pg` gives TypeScript its types. `temporal-polyfill` is a peer dependency too. It adds `Temporal`, the newer JavaScript date and time API, to runtimes such as Node.js 24 that do not have it built in. You import it yourself only when a field gives your code a `Temporal` value, which nothing on this page does; [Supported versions](/orm/supported-versions#runtimes) shows the import. `dotenv` loads `.env`, `tsx` runs `index.ts` without a build step, and `typescript` must be 5.9 or newer.

The two Prisma packages have different version numbers, for example `prisma` 8.0.0-rc.36 and `@prisma/orm-postgres` 8.0.0-rc.25. That is normal, and any two `latest` versions work together.
The command-line tool has its own version numbers, so `prisma` and `@prisma/orm-postgres` show different versions in `package.json`, which is expected.

## 2. Create the config file and `.env`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,16 @@ written
├─ .gitattributes
└─ package.json
installed
├─ @prisma/orm-mongo
├─ @prisma/orm-mongo@8.0.0-rc.28
├─ @prisma/orm-family-mongo@8.0.0-rc.28
├─ @prisma/orm-framework@8.0.0-rc.28
├─ @prisma/orm-target-mongo@8.0.0-rc.28
├─ @prisma/orm-toolchain@8.0.0-rc.28
├─ dotenv
├─ mongodb
├─ temporal-polyfill@^1.0.8
├─ prisma@latest (dev)
├─ @types/node (dev)
└─ @prisma/cli-engine@0.10.4 (dev)
└─ @types/node (dev)

✔ Done. Open prisma-8.md to get started.
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,17 @@ written
├─ .gitattributes
└─ package.json
installed
├─ @prisma/orm-postgres
├─ @prisma/orm-postgres@8.0.0-rc.28
├─ @prisma/orm-family-sql@8.0.0-rc.28
├─ @prisma/orm-framework@8.0.0-rc.28
├─ @prisma/orm-target-postgres@8.0.0-rc.28
├─ @prisma/orm-toolchain@8.0.0-rc.28
├─ dotenv
├─ @types/pg@^8.20.0
├─ pg
├─ temporal-polyfill@^1.0.8
├─ prisma@latest (dev)
├─ @types/node (dev)
└─ @prisma/cli-engine@0.10.4 (dev)
└─ @types/node (dev)

✔ Done. Open prisma-8.md to get started.
```
Expand Down
Loading
Loading