Skip to content

Brainstorm server fails on Node.js 24+ — require() in ESM context #780

@models118

Description

@models118

Bug

The brainstorm visual companion server (skills/brainstorming/scripts/server.js) fails to start on Node.js v24+ because server.js uses CommonJS require() but package.json declares "type": "module".

Error

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and
'…/superpowers/5.0.4/package.json' contains "type": "module".
To treat it as a CommonJS script, rename it to use the '.cjs' file extension.

Environment

  • OS: Windows 11 (Git Bash / MSYS2)
  • Node.js: v24.7.0
  • Superpowers: 5.0.4
  • Claude Code: latest

Steps to Reproduce

  1. Have Node.js 24+ installed
  2. Start a brainstorming session that uses the visual companion
  3. Server silently fails — no .server-info, no .server.log (in foreground mode), or error in .server.log (in background mode)

Root Cause

package.json at the superpowers root has "type": "module". Node.js 24 strictly enforces this: all .js files in the package are treated as ESM. But server.js uses require(), module.exports, etc. (CommonJS).

This likely worked on older Node.js versions that were more lenient, or before "type": "module" was added to package.json.

Fix

Rename server.jsserver.cjs and update references in start-server.sh (lines 112 and 118):

- env ... node server.js
+ env ... node server.cjs

The .cjs extension forces CommonJS regardless of package.json settings.

Workaround

Applied locally in the plugin cache:

cp scripts/server.js scripts/server.cjs
sed -i 's/node server\.js/node server.cjs/g' scripts/start-server.sh

This workaround is lost when the plugin cache is refreshed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingduplicateThis issue or pull request already exists

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions