Registry / database / embed-prisma

embed-prisma

JSON →
library3.0.0jsnpmunverified

Exposes Prisma's compiler API for NodeJS applications, enabling programmatic schema compilation, validation, TypeScript definition generation, and documentation/diagram creation without requiring the Prisma CLI. Current stable version is 3.0.0, released with a generator change from JS to TS. The library supports multiple schema files, discriminated result types (success, failure, exception), and integrates with Prisma v7. It is designed for Node.js only, not for browser environments, and is commonly used in AI-driven backend code generation pipelines.

npm install embed-prisma
INSTALL
IMPORT
SIG · EMBED-PRISMA
E
embed-prisma
databasejavascriptv3.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

EmbedPrisma
✓ import { EmbedPrisma } from 'embed-prisma'
✗ import EmbedPrisma from 'embed-prisma'
Named export, not default. ESM-only since v3; no CommonJS support.
IEmbedPrismaResult
✓ import { IEmbedPrismaResult } from 'embed-prisma'
✗ const { IEmbedPrismaResult } = require('embed-prisma')
TypeScript type import for discriminated union; do not use `require` as library is ESM-only.
EmbedPrisma
✓ const { EmbedPrisma } = await import('embed-prisma')
✗ const EmbedPrisma = require('embed-prisma')
Dynamic import for CommonJS projects; avoid `require`.

Compile a Prisma schema programmatically and inspect success/failure/exception results.

import { EmbedPrisma, IEmbedPrismaResult } from 'embed-prisma'; const prisma: EmbedPrisma = new EmbedPrisma(); const result: IEmbedPrismaResult = await prisma.compile({ "schema.prisma": ` datasource db { provider = "sqlite" url = "file:./dev.db" } generator client { provider = "prisma-client-js" } model User { id Int @id @default(autoincrement()) name String } ` }); if (result.type === "success") { console.log('Generated client at:', result.nodeModules); console.log('Documentation:', result.document); console.log('Diagrams:', result.diagrams); } else if (result.type === "failure") { console.error('Compile error:', result.reason); } else if (result.type === "exception") { console.error('Exception:', result.message); }
Debug
Known issues
breakingv3.0.0 changed generator from JS to TS. Existing custom generators written in JS may need migration.
fix
Update custom Prisma generators to TypeScript, or use v2.x if JS is required.
affects: <3.0.0
breakingv2.0.0 bumped Prisma dependency to v7. Incompatible with older Prisma versions.
fix
Upgrade Prisma to v7 or newer; pin embed-prisma to v1.x if using Prisma <7.
affects: <2.0.0
deprecatedCommonJS require() is deprecated since v3. The package is ESM-only.
fix
Use dynamic import: const { EmbedPrisma } = await import('embed-prisma');
affects: >=3.0.0
gotchaThe compile() method accepts an object with schema file names as keys; file names must include extension .prisma.
fix
Ensure keys end with '.prisma'.
affects: >=1.0.0
gotchaInstallation does not automatically include Prisma CLI dependencies; you must have a Prisma schema with a valid generator.
fix
Ensure your project has the required Prisma dependencies and generator block.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'embed-prisma'
Package not installed or wrong import path.
fix
Run 'npm install embed-prisma' and ensure import path is correct.
SyntaxError: Named export 'EmbedPrisma' not found. The requested module 'embed-prisma' is a CommonJS module which may not support all module.exports as named exports.
Using named import with require() or a bundler that misdetects module type.
fix
Use dynamic import: const { EmbedPrisma } = await import('embed-prisma');
TypeError: prisma.compile is not a function
EmbedPrisma not instantiated correctly, or wrong import.
fix
Ensure you import { EmbedPrisma } and instantiate: new EmbedPrisma()
Error: Invalid schema file name. Keys must end with '.prisma'
Passed object keys without .prisma extension.
fix
Use file names like 'schema.prisma' as keys.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
prismarequiredRuntime dependency for Prisma compiler engine; version compatibility required.
@prisma/generator-helperoptionalUsed for Prisma generator integration.
Agent activity
9 hits · last 30 days
node
8
Resources
embed-prisma — npm install embed-prisma · libregistry