{"id":26180,"library":"regexp-tree-cli","title":"regexp-tree-cli","description":"Command-line interface for the regexp-tree library (v0.0.21). Parses, optimizes, and transpiles JavaScript/ECMAScript regular expressions, producing ASTs with loc support, NFA/DFA transition tables, and compatibility transpilation. Unlike regex libraries that only match or replace, regexp-tree-cli operates at the AST level for transformations and analysis. Primarily a CLI tool, but can be used programmatically via the regexp-tree package. Last stable release is v0.0.21; development is infrequent but the underlying regexp-tree library is more actively maintained.","status":"active","version":"0.0.21","language":"javascript","source_language":"en","source_url":"https://github.com/DmitrySoshnikov/regexp-tree-cli","tags":["javascript","regexp","parser","AST","tree","JavaScript","ECMAScript"],"install":[{"cmd":"npm install regexp-tree-cli","lang":"bash","label":"npm"},{"cmd":"yarn add regexp-tree-cli","lang":"bash","label":"yarn"},{"cmd":"pnpm add regexp-tree-cli","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core regex parsing and transformation engine","package":"regexp-tree","optional":false}],"imports":[{"note":"regexp-tree is the programmatic backend; this CLI is a thin wrapper. ESM import is standard.","wrong":"const parse = require('regexp-tree').parse","symbol":"parse","correct":"import { parse } from 'regexp-tree'"},{"note":"generate converts AST back to regex string; available only from regexp-tree","wrong":"import { generate } from 'regexp-tree-cli'","symbol":"generate","correct":"import { generate } from 'regexp-tree'"},{"note":"optimize is a named export, not default","wrong":"import optimize from 'regexp-tree'","symbol":"optimize","correct":"import { optimize } from 'regexp-tree'"}],"quickstart":{"code":"npm install -g regexp-tree-cli\nregexp-tree-cli -e '/a|b/i' -o -l","lang":"bash","description":"Install CLI globally, parse a regex with location and optimizer output."},"warnings":[{"fix":"Always include slashes: regexp-tree-cli -e '/pattern/flags'","message":"The expression must be wrapped in slashes and quotes, e.g., -e '/[a-z]/i'. Omitting slashes will cause parse failure.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Use regexp-tree's compat-transpiler directly for full support.","message":"The --compat option for compat-transpiler may not cover all modern regex features (e.g., lookbehind).","severity":"deprecated","affected_versions":"<=0.0.21"},{"fix":"Use `--table` output to get formatted tables for NFA/DFA.","message":"CLI output is JSON, but with no newline at end; piping may break scripts expecting trailing newline.","severity":"gotcha","affected_versions":"<=0.0.21"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use the CLI from the terminal, or import 'regexp-tree' for programmatic use.","cause":"Trying to import the CLI package directly in Node.js code instead of using the command line.","error":"ReferenceError: regexp-tree-cli is not defined"},{"fix":"Wrap in slashes: -e '/ /' or provide a valid pattern.","cause":"Passing an expression without slashes or with an empty regex.","error":"Error: Invalid regular expression: / /: Nothing to repeat"},{"fix":"Ensure the regex is valid and pattern is enclosed in slashes.","cause":"Using --compat or --optimize on an unsupported regex, producing non-JSON output.","error":"SyntaxError: Unexpected token 'u' in JSON at position 0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}