{"id":25208,"library":"embed-prisma","title":"embed-prisma","description":"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.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/samchon/embed-prisma","tags":["javascript","prisma","compiler","schema","validation","documentation","diagram","typescript"],"install":[{"cmd":"npm install embed-prisma","lang":"bash","label":"npm"},{"cmd":"yarn add embed-prisma","lang":"bash","label":"yarn"},{"cmd":"pnpm add embed-prisma","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime dependency for Prisma compiler engine; version compatibility required.","package":"prisma","optional":false},{"reason":"Used for Prisma generator integration.","package":"@prisma/generator-helper","optional":true}],"imports":[{"note":"Named export, not default. ESM-only since v3; no CommonJS support.","wrong":"import EmbedPrisma from 'embed-prisma'","symbol":"EmbedPrisma","correct":"import { EmbedPrisma } from 'embed-prisma'"},{"note":"TypeScript type import for discriminated union; do not use `require` as library is ESM-only.","wrong":"const { IEmbedPrismaResult } = require('embed-prisma')","symbol":"IEmbedPrismaResult","correct":"import { IEmbedPrismaResult } from 'embed-prisma'"},{"note":"Dynamic import for CommonJS projects; avoid `require`.","wrong":"const EmbedPrisma = require('embed-prisma')","symbol":"EmbedPrisma","correct":"const { EmbedPrisma } = await import('embed-prisma')"}],"quickstart":{"code":"import { EmbedPrisma, IEmbedPrismaResult } from 'embed-prisma';\n\nconst prisma: EmbedPrisma = new EmbedPrisma();\nconst result: IEmbedPrismaResult = await prisma.compile({\n  \"schema.prisma\": `\n    datasource db {\n      provider = \"sqlite\"\n      url      = \"file:./dev.db\"\n    }\n    generator client {\n      provider = \"prisma-client-js\"\n    }\n    model User {\n      id    Int     @id @default(autoincrement())\n      name  String\n    }\n  `\n});\n\nif (result.type === \"success\") {\n  console.log('Generated client at:', result.nodeModules);\n  console.log('Documentation:', result.document);\n  console.log('Diagrams:', result.diagrams);\n} else if (result.type === \"failure\") {\n  console.error('Compile error:', result.reason);\n} else if (result.type === \"exception\") {\n  console.error('Exception:', result.message);\n}","lang":"typescript","description":"Compile a Prisma schema programmatically and inspect success/failure/exception results."},"warnings":[{"fix":"Update custom Prisma generators to TypeScript, or use v2.x if JS is required.","message":"v3.0.0 changed generator from JS to TS. Existing custom generators written in JS may need migration.","severity":"breaking","affected_versions":"<3.0.0"},{"fix":"Upgrade Prisma to v7 or newer; pin embed-prisma to v1.x if using Prisma <7.","message":"v2.0.0 bumped Prisma dependency to v7. Incompatible with older Prisma versions.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Use dynamic import: const { EmbedPrisma } = await import('embed-prisma');","message":"CommonJS require() is deprecated since v3. The package is ESM-only.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Ensure keys end with '.prisma'.","message":"The compile() method accepts an object with schema file names as keys; file names must include extension .prisma.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure your project has the required Prisma dependencies and generator block.","message":"Installation does not automatically include Prisma CLI dependencies; you must have a Prisma schema with a valid generator.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install embed-prisma' and ensure import path is correct.","cause":"Package not installed or wrong import path.","error":"Error: Cannot find module 'embed-prisma'"},{"fix":"Use dynamic import: const { EmbedPrisma } = await import('embed-prisma');","cause":"Using named import with require() or a bundler that misdetects module type.","error":"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."},{"fix":"Ensure you import { EmbedPrisma } and instantiate: new EmbedPrisma()","cause":"EmbedPrisma not instantiated correctly, or wrong import.","error":"TypeError: prisma.compile is not a function"},{"fix":"Use file names like 'schema.prisma' as keys.","cause":"Passed object keys without .prisma extension.","error":"Error: Invalid schema file name. Keys must end with '.prisma'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}