The Tree-sitter CLI is required to create and develop Tree-sitter parsers. There are several ways to install it.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tree-sitter/tree-sitter/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Before installing the Tree-sitter CLI, ensure you have:-
A JavaScript runtime - Tree-sitter grammars are written in JavaScript. The CLI requires Node.js (or another JavaScript runtime) to interpret grammar files. The runtime command (default:
node) must be in yourPATH. - A C Compiler - Tree-sitter creates parsers written in C. To compile and test parsers, you need a C/C++ compiler installed. The CLI will look for compilers in the standard platform locations.
Installation Methods
Cargo (Recommended)
Install from crates.io using Rust’s package manager:Build from Source
Build the CLI from source using Cargo:NPM
Install the Node.js module using npm:Pre-built Binaries
Download a binary for your platform from GitHub releases and add it to yourPATH.
Verifying Installation
After installation, verify the CLI is available:Next Steps
Once installed, you can:- Initialize a new parser project with
tree-sitter init - Create a config file with
tree-sitter init-config - Start developing your grammar
Platform-Specific Notes
macOS/iOS
You can setMACOSX_DEPLOYMENT_TARGET or IPHONEOS_DEPLOYMENT_TARGET to define the minimum supported version when building parsers.
Windows
The CLI works on Windows but some safety checks (like symbol validation withnm) are not performed.