{"id":17774,"library":"langium-cli","title":"Langium CLI","description":"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.","status":"active","version":"4.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/eclipse-langium/langium","tags":["javascript","cli","dsl","lsp","vscode","typescript"],"install":[{"cmd":"npm install langium-cli","lang":"bash","label":"npm"},{"cmd":"yarn add langium-cli","lang":"bash","label":"yarn"},{"cmd":"pnpm add langium-cli","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides the core language engineering framework and runtime for generated artifacts.","package":"langium","optional":false}],"imports":[{"note":"While langium-cli is primarily a command-line tool, this symbol is hypothesized for programmatic invocation of the 'generate' command's logic, useful for testing or custom build systems. Direct programmatic use is not the primary documented usage pattern.","symbol":"generateAction","correct":"import { generateAction } from 'langium-cli'"},{"note":"This hypothetical function represents the main entry point for programmatic execution of the CLI, analogous to `npx langium`. Its existence for public consumption is not explicitly documented, but common in TypeScript CLIs for internal or testing purposes.","symbol":"runCli","correct":"import { runCli } from 'langium-cli'"},{"note":"Represents the TypeScript interface for the `langium-config.json` schema. Useful for type-checking custom configuration builders or ensuring correct structure in programmatic contexts, but not directly used during typical CLI execution.","symbol":"LangiumConfig","correct":"import type { LangiumConfig } from 'langium-cli'"}],"quickstart":{"code":"npx langium-cli@latest init my-language\ncd my-language\nnpm install\n# Edit src/language-server/your-language.langium and langium-config.json\n# Then generate the language infrastructure:\nnpx langium-cli generate --watch\n\n# To test the generated language server:\nnpm run start","lang":"typescript","description":"Initializes a new Langium project, generates basic language infrastructure, and starts it in watch mode for development."},"warnings":[{"fix":"Review the Langium v4.0.0 changelog for detailed migration steps, focusing on `createDefaultModule` replacements (`createDefaultLangiumCoreServices`, `createDefaultLangiumGrammarServices`) and updates to `CstNode.fullText` usage.","message":"Langium v4.0.0 introduced significant breaking changes in the core API, particularly for how language services are initialized. Custom language services or extensions built directly on Langium's API might require refactoring.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"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.","message":"The `langium-cli` package, along with the core Langium framework, now requires Node.js version 20.10.0 or higher and npm version 10.2.3 or higher. Older Node.js or npm versions are no longer supported.","severity":"breaking","affected_versions":">=4.2.0"},{"fix":"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.","message":"Incorrect or missing `langium-config.json` file can lead to failed code generation or unexpected behavior. The CLI relies heavily on this configuration for identifying grammars, output paths, and generating various artifacts.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"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.","message":"When developing with `langium-cli generate --watch`, changes to grammar files will trigger regeneration. However, changes to other parts of your project (e.g., custom language server logic) may require a manual rebuild of your TypeScript project.","severity":"gotcha","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-23T00:00:00.000Z","next_check":"2026-07-22T00:00:00.000Z","problems":[{"fix":"Create a `langium-config.json` file in your project root, or specify its path using `langium generate -f <path/to/config.json>`.","cause":"The `langium generate` command could not locate the required configuration file.","error":"Error: langium-config.json not found in the current directory or specified path."},{"fix":"Use `npx langium-cli <command>` to execute it without global installation, or install globally with `npm install -g langium-cli`.","cause":"The `langium-cli` package is not installed globally or not found in the local `node_modules/.bin` directory.","error":"Error: 'langium' is not recognized as an internal or external command, operable program or batch file."},{"fix":"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.","cause":"A general error occurred during the generation process, often due to an invalid grammar, malformed configuration, or issues with output directory permissions.","error":"Error: Command failed with exit code 1: langium generate"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}