Repository navigation
Fix Node crashes from dynamic require in ESM bundle - #6
Merged
Merged
Conversation
The published CLI is an ESM bundle, so require() throws "Dynamic require of ... is not supported" under Node (npx, npm -g). This broke exporting over an existing config dir, every error-trace path, and made git commands silently fall back to the package install dir instead of the configured repo. Use static imports everywhere and ban CommonJS via lint. Also stop syncing Codex runtime data (auth.json, sessions, logs) by writing a .gitignore that only tracks Codex config. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The published CLI is an ESM bundle, so every
require()throwsDynamic require of "fs" is not supportedwhen run under Node (npx,npm -g). In practice:sync → Exportcrashed whenever it had to back up an existing config dir.paths.getRepoRoot()swallowed the failure and fell back to the package's own install dir, so git commands (push,pull,status) ran against the wrong directory.Codex sync also symlinked all of
~/.codexinto the repo, which tracked runtime data likeauth.json, sessions and logs.Fix
requirewith static imports, and enable Biome'snoCommonJsrule so it can't come back..gitignorethat tracks onlyAGENTS.md,config.toml,prompts/,rules/andskills.Verification
exportover an existing dir under Node 22: before →Dynamic require of "fs" is not supported; after → linked with a.backup.noCommonJsreports the old code and passes on the new.check:lint,check:types,buildandtestall pass; the built bundle has no__require(calls.🤖 Generated with Claude Code