Skip to content

fix: resolve ESM/CJS conflict by renaming silent-npx.js to silent-npx.cjs#21

Closed
scrossle wants to merge 4 commits intoletta-ai:mainfrom
scrossle:fix/windows-npx-console-suppression
Closed

fix: resolve ESM/CJS conflict by renaming silent-npx.js to silent-npx.cjs#21
scrossle wants to merge 4 commits intoletta-ai:mainfrom
scrossle:fix/windows-npx-console-suppression

Conversation

@scrossle
Copy link
Contributor

Fixes #20

Issue

The silent-npx.js file uses CommonJS require() syntax, but since package.json declares "type": "module", Node.js treats all .js files as ES modules. This causes the error:

ReferenceError: require is not defined in ES module scope

All hooks fail because they all go through the silent-npx.js wrapper:

  • SessionStart
    • PreToolUse
    • UserPromptSubmit
    • Stop

Solution

  • Rename hooks/silent-npx.jshooks/silent-npx.cjs
    • Update all references in hooks/hooks.json
      The .cjs extension forces Node.js to parse the file as CommonJS, regardless of the "type": "module" setting in package.json.

@scrossle
Copy link
Contributor Author

Superseded by #22 which uses a PseudoConsole (ConPTY) approach instead of the simple npx wrapper fix.

@scrossle scrossle closed this Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

silent-npx.js fails with 'require is not defined' due to ESM/CJS conflict

2 participants