Skip to content

fix: resolve ESM/CommonJS conflict in brainstorming server #774 - #784

Closed
sarbojitrana wants to merge 1 commit into
obra:mainfrom
sarbojitrana:fix/esm-commonjs-server
Closed

sarbojitrana wants to merge 1 commit into
obra:mainfrom
sarbojitrana:fix/esm-commonjs-server

Conversation

@sarbojitrana

Copy link
Copy Markdown
Contributor

Fixes #774

Resolves a runtime error in Node.js v25+ where the brainstorming server fails to start due to a module system mismatch.

Problem

The repository is configured with "type": "module" (ESM), but server.js uses CommonJS (require).

Node.js v25 enforces ESM strictly, resulting in:

ReferenceError: require is not defined in ES module scope

Solution

  • Renamed server.js → server.cjs to explicitly use CommonJS
  • Updated start-server.sh to reference the new file
  • Updated test references to maintain consistency

Before the fix

image

After the fix

image

@obra

obra commented Mar 17, 2026

Copy link
Copy Markdown
Owner

Thanks @sarbojitrana! Clean fix — exactly the right approach. Cherry-picked your commit to the dev branch (preserving your authorship). Closing the PR since we applied it directly rather than merging.

@obra obra closed this Mar 17, 2026
Fredma7c added a commit to Fredma7c/superpowers that referenced this pull request Aug 16, 2026
Per-extension `eol=lf` rules only cover the extensions someone remembered to list. Every other text file falls back to git's platform default, which on Windows is CRLF on checkout — so a fresh Windows clone reports files as modified before anything has been touched, and `git diff --ignore-all-space` returns empty because the whole diff is line endings.

29 tracked files currently have no `eol=lf` rule: .txt (9), no extension (6, including LICENSE and .gitignore), .py (6), .yml (2), .yaml (2), .svg (1), .html (1), .cjs (1), .dot (1).

The `.cjs` entry is the clearest illustration. Renaming `server.js` to `server.cjs` in 5.0.5 (obra#784) silently moved the brainstorm server out of `eol=lf` coverage, because the rules match extensions rather than intent. Adding `*.cjs` alone would fix that one instance and leave the next new file type to rediscover the same problem, so this sets `* text=auto eol=lf` as the default and keeps the explicit rules below it as documentation of which files specifically depend on LF.

`text=auto` leaves git's binary detection in place, and the explicit `binary` markings for `*.png`, `*.jpg` and `*.gif` still take precedence.

Existing checkouts pick this up with `git add --renormalize .` followed by a commit.
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.

Visual companion server.js fails on Node.js v25+ (ESM/CommonJS conflict)

2 participants