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.
PrismaDefinition
✓ import { PrismaDefinition } from 'prisma-json-schema'
✗ const { PrismaDefinition } = require('prisma-json-schema')
TypeScript types are exported as named import; CJS require will not work because package does not expose CommonJS entry for types.
schema.json
✓ import schema from 'prisma-json-schema/dist/schema.json'
✗ import schema from 'prisma-json-schema'
The JSON file is not the package main entry; you must import the dist/schema.json path explicitly.
require('prisma-json-schema/dist/schema.json')
✓ const schema = require('prisma-json-schema/dist/schema.json')
✗ const schema = require('prisma-json-schema')
CJS users must require the full path to the JSON file under dist/.
Demonstrates importing both PrismaDefinition type and the JSON schema, then validating a prisma.yml configuration object.
import { PrismaDefinition } from 'prisma-json-schema'
import schema from 'prisma-json-schema/dist/schema.json' assert { type: 'json' }
const def: PrismaDefinition = {
endpoint: process.env.PRISMA_ENDPOINT ?? 'http://localhost:4466',
secret: process.env.PRISMA_SECRET ?? 'my-secret-123',
datamodel: ['datamodel.prisma'],
generate: [{
generator: 'javascript-client',
output: './generated/prisma-client',
}],
}
// Validate against schema (using another validator like ajv)
import Ajv from 'ajv'
const ajv = new Ajv()
const validate = ajv.compile(schema)
const valid = validate(def)
if (!valid) {
console.error(validate.errors)
}
Errors
Common errors & fixes
Cannot find module 'prisma-json-schema' or its corresponding type declarations.
Missing @types/prisma-json-schema or package not installed; also package does not ship TypeScript declarations directly.
fixInstall the package: npm install prisma-json-schema. If using TypeScript, ensure strict mode is not blocking because the package provides types.
Error [ERR_REQUIRE_ESM]: require() of ES Module .../prisma-json-schema/dist/schema.json not supported.
Trying to require() a JSON file in a CJS context without the proper extension or Node version.
fixUse const schema = require('prisma-json-schema/dist/schema.json') (works in Node 12+). Or switch to ESM import. TypeError: Cannot read properties of undefined (reading 'properties')
Using the package index export (which is undefined) instead of the schema.json file.
fixImport from 'prisma-json-schema/dist/schema.json' instead of the package root.
Audit
Dependencies
No dependency data recorded yet.