Skip to main content
Watch: I Built an AI App Without Leaving Databricks

Gemini CLI error

Gemini CLI: SyntaxError: Invalid regular expression flags

Error message
SyntaxError: Invalid regular expression flags

Status: By designLast verified 1 documented fix3 sources

What it means

The CLI crashes on startup inside a dependency (for example node_modules/string-width/index.js) because the Node.js runtime is too old for the regex syntax it uses.

Causes

  • Running on Node.js 18 (the report shows Node.js v18.20.4). Gemini CLI requires Node.js 20.0.0+ (installation docs; package engines "node": ">=20.0.0"). The minimum was raised to Node 20 in #3277.

How to fix it

  1. Fix 1.

    Upgrade Node.js to version 20 or later, then reinstall. Maintainer skeshive in #14739: "Can you try updating to node version 20? Looks like you're on 18".

    Terminal
    npm install -g @google/gemini-cli@latest

More Gemini CLI errors

All 19 Gemini CLI errors

FAQ

What does "SyntaxError: Invalid regular expression flags" mean in Gemini CLI?

The CLI crashes on startup inside a dependency (for example node_modules/string-width/index.js) because the Node.js runtime is too old for the regex syntax it uses.

How do I fix "SyntaxError: Invalid regular expression flags"?

Upgrade Node.js to version 20 or later, then reinstall. Maintainer skeshive in #14739: "Can you try updating to node version 20? Looks like you're on 18".

Is this Gemini CLI error fixed?

Status: By design. Expected behavior, not a bug. The documented fixes change the setup that triggers it. Affected versions: Any release on Node.js below 20; Node 20 minimum since v0.1.10 (#3277); reported on 0.19.4 (#14739)

Sources

Last verified against 3 sources: official docs, maintainer replies and release notes.

Newsletter

Fixes for the tools you use, weekly

One email per week. New coding agent releases, what broke, and how developers are working around it.