Skip to content

SyntaxError: Invalid or unexpected token #15

@wolfand11

Description

@wolfand11
CURSOR_AGENT_NODE=D:\Applications\nodejs\node.exe
CURSOR_AGENT_SCRIPT=C:\Users\admin\AppData\Local\cursor-agent\cursor-agent.CMD
cursor-api-proxy listening on http://127.0.0.1:8765
- agent bin: agent
- workspace: D:\Documents\MyAgents\CursorProxy\.node_env
- mode: ask
- default model: auto
- force: false
- approve mcps: false
- required api key: no
- sessions log: D:\.cursor-api-proxy\sessions.log
- chat-only workspace: no
- verbose traffic: no
- max mode: yes (CURSOR_BRIDGE_MAX_MODE=true)
- Windows cmdline budget: 30000 (prompt tail truncation when over limit; Windows only)
[2026-03-26T02:36:41.170Z] Incoming: POST /v1/chat/completions (from 127.0.0.1)
[2026-03-26T02:36:41.178Z] Windows: prompt truncated for CreateProcess limit (59069 -> 14499 chars, tail preserved).
[2026-03-26T02:36:46.806Z] Agent error: Cursor CLI failed (exit 1): C:\Users\admin\AppData\Local\cursor-agent\cursor-agent.CMD:1
@echo off
^

SyntaxError: Invalid or unexpected token
    at wrapSafe (node:internal/modules/cjs/loader:1624:18)
    at Module._compile (node:internal/modules/cjs/loader:1666:20)
    at Object..js (node:internal/modules/cjs/loader:1824:10)
    at Module.load (node:internal/modules/cjs/loader:1427:32)
    at Module._load (node:internal/modules/cjs/loader:1250:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
    at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:152:5)
    at node:internal/main/run_main_module:33:47

Node.js v24.4.1

I encountered the above error.

The AI's analysis of this error is as follows. The AI saw the error, but I suspect its analysis of the cause is incorrect.

The actual failure is:

C:\Users\admin\AppData\Local\cursor-agent\cursor-agent.CMD:1
@echo off
^
SyntaxError: Invalid or unexpected token
That means node.exe is trying to execute the batch file cursor-agent.cmd as if it were JavaScript. The first line of a .cmd file is @echo off, so Node immediately throws a syntax error.

Why it’s happening:

you sets CURSOR_AGENT_NODE and CURSOR_AGENT_SCRIPT.
CURSOR_AGENT_SCRIPT is currently resolved to cursor-agent.cmd.
In cursor-api-proxy, when both vars are set on Windows, it directly runs node <CURSOR_AGENT_SCRIPT> ... without translating .cmd to index.js.
So the bug is effectively: CURSOR_AGENT_SCRIPT points at the wrapper instead of the real JS entrypoint.

The fix is to either:

set CURSOR_AGENT_SCRIPT to the real agent JS file, such as C:\Users\admin\AppData\Local\cursor-agent\versions\2026.01.28-fd13201\index.js, or
stop setting CURSOR_AGENT_NODE/CURSOR_AGENT_SCRIPT and let the proxy use its normal Windows path.
If you want, I can patch CursorProxy/cursor_proxy.py to resolve the real index.js automatically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions