ruvnet / ruvnet/agentic-flow

Bug: __dirname is not defined in ESM context (agentdb-cli.js)

Open Beginner friendly
#82 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
812
Forks
175
Avg merge
2m
Merged PRs (30d)
3

Description

Description

When running agentdb CLI commands in a project with "type": "module" in package.json, the CLI fails with:

❌ __dirname is not defined

Root Cause

dist/agentdb/cli/agentdb-cli.js line 55 uses __dirname:

const schemaPath = path.join(__dirname, '../schemas/frontier-schema.sql');

But __dirname is a CommonJS global that doesn't exist in ESM modules.

Fix

Add ESM compatibility shim at the top of the file:

import { fileURLToPath } from 'url';
import { dirname } from 'path';

// ESM compatibility fix for __dirname
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

Environment

  • Node.js: v22.x
  • agentic-flow: 1.10.2
  • OS: macOS
  • Project type: ESM ("type": "module" in package.json)

Workaround

Using pnpm patch to apply the fix locally until this is released.

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Start with dist/agentdb/cli/agentdb-cli.js around line 55 and inspect how the CLI locates ../schemas/frontier-schema.sql. Run the agentdb CLI in a project whose package.json sets "type": "module", then verify the schema path resolves without the __dirname error and confirm normal CLI commands still work.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.