Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

contract emit crashes (CLI.UNEXPECTED, ERR_INVALID_ARG_VALUE) with the relative contract path that orm init scaffolds

Closed
#205 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
node.js, typescript
Domain
cli, tooling

Research direction

Start at cli-engine's loadConfig and trace how the relative contract path becomes projectRoot before validateContractDeps calls createRequire. Reproduce the default orm init scaffold and contract emit flow, then verify that the relative path works without ERR_INVALID_ARG_VALUE and that contract.json and contract.d.ts are emitted successfully.

Written by the indexing model from the issue text.

Description

Summary

orm init scaffolds prisma.config.ts with a relative contract path:

orm: ormConfig({
  contract: "./src/prisma/contract.prisma",
  db: { connection: process.env['DATABASE_URL']! },
}),

With that config, contract emit crashes:

CLI.UNEXPECTED: The argument 'filename' must be a file URL object, file URL string, or absolute path
string. Received './src/prisma/package.json'  (ERR_INVALID_ARG_VALUE)

Changing the config to an absolute path (new URL('./src/prisma/contract.prisma', import.meta.url).pathname) makes the same command succeed and emit contract.json/contract.d.ts normally.

Where it breaks

In @prisma/[email protected] (dist ref-*.mjs), validateContractDeps does:

const resolve = createRequire(`${projectRoot}/package.json`);

and projectRoot arrives as the relative ./src/prisma derived from the config's contract path, but node:module's createRequire requires an absolute path or file URL. Either the config loader should absolutize contract against the config file's directory before handing it to the toolchain, or the toolchain should resolve projectRoot to an absolute path itself.

Filing here because the repro is entirely through prisma-cli commands and the config loader (cli-engine loadConfig) may be the layer that should absolutize; transfer to the ORM repo if it's purely an orm-toolchain fix.

Repro caveat

Reproduced on macOS / Node 24.11.1 with the rc.4 CLI shell and a locally patched @prisma/cli-engine built from repo HEAD, because the published engine crashes the CLI at startup (#202). I could not verify against a fully published stack for that reason. Today users hit this bug's surface anyway: orm init's final emit step fails with CLI.INIT_EMIT_FAILED due to #202, and once that is fixed, this crash is the next thing the default scaffold + contract emit flow runs into (unless the published engine absolutizes the path where the HEAD engine does not).

Found while validating the docs quickstart end to end (prisma/web#8151).

🤖 Filed with Claude Code on behalf of [email protected]

Dominant language
TypeScript
Stars
21
Forks
2
Avg merge
16h 42m
Merged PRs (30d)
40

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from prisma/prisma-cli

All issues in prisma/prisma-cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.