MiniMax-AI / MiniMax-AI/minimax-code
[Bug]: MiniMax Code CLI fails with SyntaxError on first invocation
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.3k
- Forks
- 141
- Avg merge
- 2h 45m
- Merged PRs (30d)
- 46
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 --help
Expected 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the failure with mavis mcp ls or mavis memory append --help, then inspect the shipped resources/daemon/cli.js and resources/daemon/package.json. Trace the launcher path indicated by the CommonJS stack and determine which ESM-compatible entry approach fits the package. Done means the CLI starts and the listed MCP and memory commands no longer fail with SyntaxError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- build-system, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100