Skip to content

Commit c044b25

Browse files
authored
fix(memos-local-plugin): Node.js v23 built-in TypeScript breaks bridge.cts (#1484)
## Summary - Node.js v23.6+ enables `--experimental-strip-types` by default, causing its native `.cts` handler (`Object.loadCTS`) to take precedence over `tsx`. The native handler only strips type annotations without transforming ESM `import` to `require()`, resulting in `SyntaxError: Cannot use import statement outside a module` when loading `bridge.cts`. - Set `NODE_OPTIONS='--no-experimental-strip-types'` when Node >= 23 is detected in both `daemon_manager.py` (hermes + openharness adapters) and `install.sh`, so `tsx` fully handles the compilation. ## Error reproduced ``` (node:70572) Warning: Failed to load the ES module: bridge.cts SyntaxError: Cannot use import statement outside a module at Object.loadCTS [as .cts] (node:internal/modules/cjs/loader:1797:10) ``` ## Files changed | File | Change | |------|--------| | `adapters/hermes/daemon_manager.py` | Detect Node >= 23, set `--no-experimental-strip-types` in env before launching daemon | | `adapters/openharness/scripts/daemon_manager.py` | Same fix for openharness adapter | | `install.sh` | Export `NODE_OPTIONS` in environment check when Node >= 23 detected | ## Test plan - [ ] Install plugin on Node.js v23.x — daemon should start without `SyntaxError` - [ ] Install plugin on Node.js v22.x (LTS) — no regression, `NODE_OPTIONS` not set - [ ] Verify memory viewer accessible at `http://127.0.0.1:18901` after install on Node 23
2 parents 1f80180 + 7ba2b81 commit c044b25

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

apps/memos-local-plugin/adapters/hermes/daemon_manager.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,20 @@ def start_daemon(
123123
env["MEMOS_BRIDGE_CONFIG"] = json.dumps(get_bridge_config())
124124
env["OPENCLAW_STATE_DIR"] = str(get_daemon_dir().parent)
125125

126+
# Node.js v23.6+ enables --experimental-strip-types by default, which
127+
# causes its native .cts handler to take precedence over tsx. The native
128+
# handler only strips types without transforming ESM imports to require(),
129+
# breaking bridge.cts. Disable it so tsx handles the compilation.
130+
try:
131+
node_ver = subprocess.check_output(["node", "-v"], text=True).strip()
132+
major = int(node_ver.lstrip("v").split(".")[0])
133+
if major >= 23:
134+
existing = env.get("NODE_OPTIONS", "")
135+
if "--no-experimental-strip-types" not in existing:
136+
env["NODE_OPTIONS"] = f"--no-experimental-strip-types {existing}".strip()
137+
except (subprocess.CalledProcessError, ValueError, FileNotFoundError):
138+
pass
139+
126140
log_dir = get_daemon_dir()
127141

128142
logger.info("Starting daemon: %s", " ".join(bridge_cmd))

apps/memos-local-plugin/adapters/openharness/scripts/daemon_manager.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,20 @@ def start_daemon(
126126
# Isolate viewer: prevent migration scan from showing OpenClaw data
127127
env["OPENCLAW_STATE_DIR"] = str(get_daemon_dir().parent)
128128

129+
# Node.js v23.6+ enables --experimental-strip-types by default, which
130+
# causes its native .cts handler to take precedence over tsx. The native
131+
# handler only strips types without transforming ESM imports to require(),
132+
# breaking bridge.cts. Disable it so tsx handles the compilation.
133+
try:
134+
node_ver = subprocess.check_output(["node", "-v"], text=True).strip()
135+
major = int(node_ver.lstrip("v").split(".")[0])
136+
if major >= 23:
137+
existing = env.get("NODE_OPTIONS", "")
138+
if "--no-experimental-strip-types" not in existing:
139+
env["NODE_OPTIONS"] = f"--no-experimental-strip-types {existing}".strip()
140+
except (subprocess.CalledProcessError, ValueError, FileNotFoundError):
141+
pass
142+
129143
log_dir = get_daemon_dir()
130144

131145
logger.info("Starting daemon: %s", " ".join(bridge_cmd))

apps/memos-local-plugin/install.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ else
122122
error "需要 Node.js >= 18,当前: $(node -v)"
123123
exit 1
124124
fi
125+
if [[ "$NODE_VERSION" -ge 23 ]]; then
126+
info "Node.js >= 23 detected — disabling built-in TypeScript to avoid tsx conflict"
127+
export NODE_OPTIONS="--no-experimental-strip-types ${NODE_OPTIONS:-}"
128+
fi
125129
success "Node.js $(node -v)"
126130
fi
127131

0 commit comments

Comments
 (0)