Files
jackwener__opencli/docs/guide/troubleshooting.md
jakevin f481585ba1 chore: drop util.styleText to support Node v20+ (#1524)
* chore: drop util.styleText to support Node v20+

util.styleText was added in Node v21.7.0 / v20.12.0. v21.0.0-v21.6.x and
v20.0.0-v20.11.x throw `SyntaxError: ... styleText` at startup because the
import resolves before any user code runs (a real user reported this on
v21.2.0).

OpenCLI is primarily agent-facing — terminal colors are noise to consumers,
and the [OK] / [WARN] / [FAIL] / ℹ / ⚠ / ✖ markers we already write carry
the semantic info that colors only repeated. Strip styleText entirely from
logger / output / doctor / tui / update-check / cli / download/progress /
commands/daemon and clean up the resulting awkward `${'literal'}` template
fragments. engines.node now reads ">=20.0.0".

This removes the Node-version coupling that A/B fixes would only have
papered over.

* fix(runtime): truly support Node v20+ by aligning guard + undici

Follow-up to the styleText removal: declaring engines.node >=20.0.0 is
not enough on its own. Two coupled barriers remained:

- src/runtime-detect.ts: MIN_SUPPORTED_NODE_MAJOR = 21 explicitly
  rejected v20 at startup
- undici@^8.0.2 declares engines.node >=22.19.0; Node 20/21 crash on
  webidl.util.markAsUncloneable before any user code runs

Lower the guard to 20 and downgrade undici to ^6.25.0 (engines >=18.17,
retains Agent / EnvHttpProxyAgent / fetch / Dispatcher). Smoke-tested
--help / doctor / list on Node v20.0.0, v21.2.0, v22.22.2. 213/213
targeted unit tests pass.
2026-05-13 18:33:21 +08:00

1.9 KiB

Troubleshooting

Common Issues

"Extension not connected"

  • Ensure the opencli Browser Bridge extension is installed and enabled in chrome://extensions.
  • Run opencli doctor to diagnose connectivity.

Empty data or 'Unauthorized' error

  • Your login session in Chrome might have expired. Open a normal Chrome tab, navigate to the target site, and log in or refresh the page.
  • Some sites have geographic restrictions (e.g., Bilibili, Zhihu from outside China).

Browser command opens the page but still cannot read context

  • A healthy Browser Bridge connection does not guarantee that the current page target exposes the data your adapter expects.
  • Some browser adapters are sensitive to the active host or page context.
  • Example: opencli 1688 item may fail with did not expose product context if the target is too broad.
  • Retry on a real item page, refresh the page in Chrome, and if needed narrow the target, for example:
OPENCLI_CDP_TARGET=detail.1688.com opencli 1688 item 841141931191 -f json

Node API errors

  • Make sure you are using Node.js >= 20. Run node --version to verify.

Daemon issues

# View extension logs
curl localhost:19825/logs

# Stop the daemon
opencli daemon stop

# Full diagnostics
opencli doctor

The daemon is persistent and stays alive until explicitly stopped (opencli daemon stop) or the package is uninstalled.

Desktop adapter connection issues

For Electron/CDP-based adapters (Cursor, Codex, etc.):

  1. Make sure the app is launched with --remote-debugging-port=XXXX
  2. Verify the endpoint is set: echo $OPENCLI_CDP_ENDPOINT
  3. Test the endpoint: curl http://127.0.0.1:XXXX/json/version

Build errors

# Clean rebuild
rm -rf dist/
npm run build

# Type check
npx tsc --noEmit

Getting Help

  • GitHub Issues — Bug reports and feature requests
  • Run opencli doctor for comprehensive diagnostics