Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default (plugin)
✓ // In .prettierrc: { "plugins": ["prettier-plugin-prisma"] }
✗ // Adding to plugins array without installing the package
No explicit import needed; Prettier discovers the plugin automatically when installed. Also works with `prettier --plugin prettier-plugin-prisma`.
default (CommonJS require for programmatic use)
✓ const prettierPluginPrisma = require('prettier-plugin-prisma');
✗ const prettierPluginPrisma = require('prettier-plugin-prisma').default;
The plugin is CommonJS-compatible; require directly returns the plugin object.
default (ESM import for programmatic use)
✓ import prettierPluginPrisma from 'prettier-plugin-prisma';
✗ import * as prettierPluginPrisma from 'prettier-plugin-prisma';
ESM import works; the package has a 'default' export. TypeScript users may need `esModuleInterop`.
PluginOptions (TypeScript type)
✓ import type { PluginOptions } from 'prettier-plugin-prisma';
✗ import { PluginOptions } from 'prettier-plugin-prisma';
PluginOptions is a type-only export; use `import type` to avoid runtime errors.
Demonstrates installing the plugin, configuring Prettier to use it, and formatting a .prisma schema file.
// 1. Install
npm i -D prettier prettier-plugin-prisma
// 2. In .prettierrc (JSON or YAML)
{
"plugins": ["prettier-plugin-prisma"],
"tabWidth": 2,
"printWidth": 100
}
// 3. Create a Prisma file: schema.prisma
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
posts Post[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Post {
id Int @id @default(autoincrement())
title String
content String?
author User @relation(fields: [authorId], references: [id])
authorId Int
createdAt DateTime @default(now())
}
// 4. Run Prettier
npx prettier --write schema.prisma
Errors
Common errors & fixes
Cannot find module 'prettier-plugin-prisma'
Plugin not installed or Prettier cannot locate it.
fixRun `npm install -D prettier-plugin-prisma` and ensure it's listed in package.json devDependencies.
Error: No plugin detected for "*.prisma" files.
Prettier is not configured to use the plugin.
fixAdd `"plugins": ["prettier-plugin-prisma"]` to your .prettierrc file.
TypeError: prettierPluginPrisma.default is not a function
Using CommonJS require incorrectly when plugin exports a single default object.
fixUse `const prettierPluginPrisma = require('prettier-plugin-prisma');` without `.default`. Prettier failed to load plugin due to WebAssembly.instantiateStreaming
WASM binary failed to load, possibly due to Content Security Policy or unsupported Node version.
fixEnsure Node.js >=14 and no CSP blocking WASM. Use `--no-wasm` or upgrade Node.js.
Audit
Dependencies
prettierrequiredPeer dependency; plugin requires Prettier >=2 or >=3 to function.
@prisma/prisma-schema-wasmrequiredCore formatting logic; Wasm binary compiled from Prisma's official formatter.