Registry / development / schema-dts-gen

schema-dts-gen

JSON →
library2.0.0jsnpmunverified

CLI tool (v2.0.0) that generates TypeScript type definitions (.d.ts) from Schema.org and compatible ontology vocabularies. Powers the schema-dts package. Processes .nt files via --ontology flag, produces complete TS types for JSON-LD structured data. Only generator in its space, actively maintained on GitHub. Requires Node >=14 and TypeScript >=4.9.5.

npm install schema-dts-gen
INSTALL
IMPORT
SIG · SCHEMA-DTS-GEN
S
schema-dts-gen
developmentjavascriptv2.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.

default
import gen from 'schema-dts-gen'
const gen = require('schema-dts-gen')
ESM-only; CJS require fails. The package is primarily a CLI tool; programmatic usage is possible but undocumented.
VOCABULARY
import { VOCABULARY } from 'schema-dts-gen'
import VOCABULARY from 'schema-dts-gen'
Named export for vocabulary path constant, not default.
run
import { run } from 'schema-dts-gen'
const { run } = require('schema-dts-gen')
ESM named export; CJS dynamic import required.
types
import { Thing } from 'schema-dts'
import { Thing } from 'schema-dts-gen'
Generated types are in schema-dts package, not schema-dts-gen.

Install and run schema-dts-gen to generate TypeScript types from Schema.org ontology, then import generated types from schema-dts.

npm install --save-dev schema-dts-gen npx schema-dts-gen --ontology=https://schema.org/version/latest/schemaorg-all-https.nt # Generates schema.d.ts in current directory. # Use generated types: import { Thing } from 'schema-dts'; const item: Thing = { '@type': 'Book', name: '1984' };
Debug
Known issues
breakingv2.0.0 changed from CommonJS to ESM-only. require() will fail with ERR_REQUIRE_ESM.
fix
Use import or dynamic import(). For scripts, rename to .mjs or set 'type':'module' in package.json.
affects: >=2.0.0
deprecatedThe --context option with multiple name:URL pairs is deprecated; use --context single URL or --context-list instead.
fix
Use --context-list for multiple contexts, e.g., --context-list name1:url1,name2:url2.
affects: >=1.0.0
gotchaGenerated types depend on schema-dts package; if not installed, TS compiler errors about missing module.
fix
Run 'npm install --save-dev schema-dts' in addition to schema-dts-gen.
affects: >=1.0.0
gotchaThe --ontology file must be in .nt format; other formats like .ttl or .jsonld will fail silently or produce wrong types.
fix
Convert ontology to NTriples (.nt) before passing to generator.
affects: >=1.0.0
breakingv2.0.0 dropped Node <14 support. Oldest supported Node version moved from 12 to 14.
fix
Upgrade Node.js to >=14 or stay on schema-dts-gen v1.x.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'schema-dts-gen'
Package not installed (dev dependency).
fix
npm install --save-dev schema-dts-gen
SyntaxError: Unexpected token 'export'
Using require() with ESM-only package v2+.
fix
Switch to import or enable ESM in your project.
TypeError: (intermediate value).run is not a function
Trying to programmatically call run() but it is a named export, not default.
fix
Use import { run } from 'schema-dts-gen' instead of default import.
error TS2307: Cannot find module 'schema-dts' or its corresponding type declarations.
Generated .d.ts imports from schema-dts, which is not installed.
fix
npm install --save-dev schema-dts
Error: Unsupported ontology format. Expected .nt file.
Provided ontology file is not in NTriples format.
fix
Download ontology as .nt or convert via tools like 'rapper' or 'rdfpipe'.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
typescriptrequiredPeer dependency for TS compilation of generated types
Agent activity
38 hits · last 30 days
node
34
Resources
schema-dts-gen — npm install schema-dts-gen · libregistry