The Langium CLI (`langium-cli`) is the command-line interface for the Eclipse Langium framework, a powerful toolset for building domain-specific languages (DSLs) with full language server protocol (LSP) support. Currently at stable version 4.2.1, it follows a regular release cadence with minor versions released every few months and major versions annually or as significant breaking changes necessitate. Its primary function is to generate the core language infrastructure—including parsers, ASTs, and language server components—from a Langium grammar definition file. It differentiates itself by deeply integrating with TypeScript and VS Code, providing a robust foundation for creating custom programming languages and their development tooling efficiently, without manual boilerplate code generation. The CLI requires a configuration file, `langium-config.json`, to specify language details, grammar paths, and output targets for various artifacts like TextMate syntax highlighting, Monarch syntax highlighting, Prism syntax highlighting, and railroad diagrams.
npm install langium-cliVerified import paths — ran on the pinned version, not inferred.
Initializes a new Langium project, generates basic language infrastructure, and starts it in watch mode for development.
Review the Langium v4.0.0 changelog for detailed migration steps, focusing on `createDefaultModule` replacements (`createDefaultLangiumCoreServices`, `createDefaultLangiumGrammarServices`) and updates to `CstNode.fullText` usage.
Upgrade your Node.js environment to >=20.10.0 and npm to >=10.2.3 using a tool like nvm (Node Version Manager) or by updating your system's Node.js installation.
Ensure a valid `langium-config.json` exists in your project root or is specified via the `--file` option. Refer to the Langium documentation for the correct schema and example configurations.
Run `npm run build` or your project's TypeScript compilation command after making changes to non-grammar source files. The `--watch` flag only applies to grammar regeneration.
Create a `langium-config.json` file in your project root, or specify its path using `langium generate -f <path/to/config.json>`.
Use `npx langium-cli <command>` to execute it without global installation, or install globally with `npm install -g langium-cli`.
Inspect the console output for more specific error messages from the Langium generator. Verify your `.langium` grammar file for syntax errors and ensure `langium-config.json` is correctly structured and paths are valid.