Skip to content

[Tooling] loading genkit-tools.conf.js from an ESM app fails #131

@pavelgj

Description

@pavelgj
node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/pavel/genkit/js/samples/rag/genkit-tools.conf.js from /Users/pavel/genkit/genkit-tools/common/lib/cjs/plugin/config.js not supported.
genkit-tools.conf.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead either rename genkit-tools.conf.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /Users/pavel/genkit/js/samples/rag/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

    at /Users/pavel/genkit/genkit-tools/common/lib/cjs/plugin/config.js:90:91
    at async findToolsConfigInternal (/Users/pavel/genkit/genkit-tools/common/lib/cjs/plugin/config.js:90:29) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v21.7.3

to reproduce set "type": "module", in js/samples/rag/package.json

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtooling

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions