Repository navigation
[Bug]: MiniMax Code CLI fails with SyntaxError on first invocation #103
Description
Version / 版本号
v 3.0.47 (3.0.47.76)
Platform / 平台
macOS
OS version / 系统版本
Monterey
Issue area / 问题类型
MCP / OAuth / integration
Upload ID / 日志上传 ID
415143477977153
What happened? / 问题描述
Summary
Every mavis * CLI command (e.g. mavis mcp ls, mavis memory append, mavis mcp call) fails immediately with a Node.js SyntaxError on line 2 of the shipped CLI entry point. The CLI file cli.js is an ES module being loaded via Node's CommonJS loader.
Environment
- App: MiniMax Code (
/Applications/MiniMax Code.app) Version 3.0.47 (3.0.47.76) - Platform: macOS (MOnterey / Sonoma / any recent; version-independent — reproduces on any host Node version because the bug is in the file itself, not the runtime)
- App entry:
/Applications/MiniMax Code.app/Contents/Resources/resources/daemon/cli.js - App package:
…/daemon/package.json→{"type":"module","version":"3.0.47"}✓ ("type": "module"is already declared) - System Node:
v9.6.1(/usr/local/bin/node) — but the app presumably uses a bundled Node; reproduces regardless
Root cause
cli.js is an ES module — line 2 uses top-level import. The packaging metadata correctly marks it as such (the file's own package.json has "type": "module"). However the launcher script that invokes it is using require() / Module._load (visible in the stack trace: module._compile, module._extensions..js) — i.e. the CommonJS loader.
This is a packaging bug. The CLI cannot load until the launcher is changed to use ESM-aware loading.
Suggested fix (for the maintainer)
Any of these will resolve it:
-
Rename the entry so Node picks the right loader by extension:
mv resources/daemon/cli.js resources/daemon/cli.mjs
and update the launcher shim to requirecli.mjs. (MJS files skip the CJS loader entirely even without"type": "module"in package.json.) -
Use a CJS wrapper that imports the ESM file via dynamic import:
// resources/daemon/cli.cjs (async () => { const cli = await import('./cli.js'); cli.main(process.argv.slice(2)); })();
and have the launcher invoke
cli.cjs. -
Fix the launcher to do
await import('./daemon/cli.js')instead ofrequire('./daemon/cli.js').
Option 1 is the smallest, most surgical patch.
Impact
- Any user trying to manage MCP servers via CLI (
mavis mcp ls/call/tools list), manage memory (mavis memory append), or any othermavis *subcommand is fully blocked. - MCP server functionality is not affected — the daemon process (
MiniMax Code.app/Contents/MacOS/MiniMax Code) loads its own modules correctly (it's loaded by Electron under ESM-aware paths) and serves MCP configs via the daemon transport. Only the standalone CLI wrapper is broken. - Workaround until patched: drive the daemon via its HTTP transport directly (e.g.
curl http://127.0.0.1:15321/mavis/...), or edit~/.mavis/mcp/mcp.jsonby hand.
Reporter
Local macOS user, MiniMax Code build that ships cli.js as the daemon CLI entry. No data loss; just unusable CLI.
Steps to reproduce / 复现步骤
mavis mcp ls
# OR
mavis memory append --helpExpected behavior / 预期行为
CLI runs, lists MCP servers, prints help, etc.
Actual behavior / 实际行为
/Applications/MiniMax Code.app/Contents/Resources/resources/daemon/cli.js:2
import { createRequire as __mavis_cR } from "module"; const require = __mavis_cR(import.meta.url);
^^^^^^
SyntaxError: Unexpected token import
at new Script (vm.js:51:7)
at createScript (vm.js:138:10)
at Object.runInThisContext (vm.js:199:10)
at Module._compile (module.js:626:28)
at Object.Module._extensions..js (module.js:673:10)
at Module.load (module.js:575:32)
at tryModuleLoad (module.js:515:12)
at Function.Module._load (module.js:507:3)
at Function.Module.runMain (module.js:703:10)
at startup (bootstrap.js:193:16)
Logs or crash report / 日志或崩溃信息
General → Upload logs and include the generated upload ID" — but our crash is pre-execution so the log upload may have nothing;Screenshots / 截图
No response
Before submitting / 提交前确认
- I have searched existing issues.
- I am using the latest version available to me.
- I have removed sensitive information from logs/screenshots.
Activity
hetaoBackend commentedon Sep 21, 2026
Acknowledged — loading an ESM
cli.jsthrough the CommonJS loader is a packaging bug in the 3.0.47-eramavisCLI entry. The CLI entry has been reworked in later builds; could you retest on the latest version? If the SyntaxError persists there, please share the exact version + first lines of the shippedcli.jsand we'll fix the loader declaration directly.hetaoBackend commentedon Oct 19, 2026
Closing as part of a backlog cleanup: this issue was filed more than a month ago against an older release, and the codebase has changed substantially since then. If it still reproduces on the latest version, please open a new issue with the current version and reproduction steps. Thank you for the report!
批量清理积压:该 issue 创建已超过一个月,针对的是较旧版本,代码已有较大变化。如果在最新版本上仍能复现,欢迎附上当前版本号和复现步骤重新提交 issue。感谢反馈!