{"id":10566,"library":"bash-language-server","title":"Bash Language Server","description":"The Bash Language Server provides an IDE-like experience for Bash scripts by implementing the Language Server Protocol. It leverages Tree Sitter for parsing, and integrates with external tools like ShellCheck for linting, shfmt for formatting, and explainshell for documentation. The current stable version is 5.6.0. It follows a frequent release cadence, indicated by multiple minor and patch releases within short periods. A key differentiator is its comprehensive integration with established Bash tooling, offering features such as jump to definition, find references, code completion, diagnostics, and formatting. It requires Node.js version 16 or newer to run, and ships with TypeScript types, allowing for type-safe client development or custom integrations. Primarily used as a standalone server, it's typically invoked by editor clients rather than imported as a library.","status":"active","version":"5.6.0","language":"javascript","source_language":"en","source_url":"https://github.com/bash-lsp/bash-language-server","tags":["javascript","typescript"],"install":[{"cmd":"npm install bash-language-server","lang":"bash","label":"npm"},{"cmd":"yarn add bash-language-server","lang":"bash","label":"yarn"},{"cmd":"pnpm add bash-language-server","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for linting and advanced diagnostics.","package":"shellcheck","optional":false},{"reason":"Required for document formatting.","package":"shfmt","optional":false}],"imports":[{"note":"This is the core server entry point, typically invoked by the CLI. Direct import is for advanced use cases like embedding the server or custom test runners, and uses an internal path.","symbol":"startServer","correct":"import { startServer } from 'bash-language-server/lib/server';"},{"note":"Imports the TypeScript interface for server configuration settings. Useful for type-checking when creating custom configuration providers or working with the server's internal structure.","symbol":"Settings","correct":"import { Settings } from 'bash-language-server/lib/config';"},{"note":"Provides the internal logger interface, useful if developing custom extensions or debugging server behavior programmatically. This is for advanced usage.","symbol":"Logger","correct":"import { Logger } from 'bash-language-server/lib/util/logger';"}],"quickstart":{"code":"import { startServer } from 'bash-language-server/lib/server';\nimport { exec } from 'child_process';\n\n// This package is primarily a CLI tool (bash-language-server start)\n// for editor integration. The following demonstrates how to verify\n// its global installation and provides a conceptual programmatic hook.\n\nconsole.log('Verifying bash-language-server installation...');\n\nexec('bash-language-server --version', (error, stdout, stderr) => {\n  if (error) {\n    console.error(`Error checking server version: ${error.message}`);\n    console.error('Please ensure bash-language-server is installed globally: npm i -g bash-language-server');\n    return;\n  }\n  if (stderr) {\n    console.error(`Server stderr: ${stderr}`);\n  }\n  console.log(`Bash Language Server installed and version: ${stdout.trim()}`);\n  console.log('\\nTo use it, configure your editor (e.g., VS Code, Neovim) to use `bash-language-server start` as its LSP server command.');\n  \n  // For advanced, programmatic usage (e.g., custom testing or embedding),\n  // one might theoretically import 'startServer' from 'bash-language-server/lib/server'.\n  // However, this function expects a Language Server Protocol connection object\n  // (e.g., from 'vscode-languageserver/node') which is outside a simple quickstart.\n  // Example of how it *might* be used in a highly custom setup:\n  // const connection = createConnection(ProposedFeatures.all);\n  // connection.onInitialize((params) => { /* ... */ });\n  // connection.listen();\n  // startServer(connection);\n});","lang":"typescript","description":"Demonstrates global installation verification and clarifies how the Bash Language Server is typically used via editor integrations rather than direct programmatic imports."},"warnings":[{"fix":"Install shellcheck (e.g., 'sudo apt install shellcheck') and shfmt (e.g., 'go install mvdan.cc/sh/cmd/shfmt@latest') via your system's package manager or appropriate installation method.","message":"Full functionality, including linting and formatting, relies on external tools like ShellCheck and shfmt. Not installing these will result in missing features.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade your Node.js installation to version 16 or later (e.g., using nvm: 'nvm install 18 && nvm use 18').","message":"Requires Node.js version 16 or newer. Older Node.js versions are not supported and will prevent the server from running.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Upgrade to bash-language-server version 5.5.0 or newer to resolve the `shfmt` environment variable deprecation warning.","message":"Prior to version 5.5.0, `shfmt` environment variable deprecation warnings could appear due to an underlying dependency. This was resolved in version 5.5.0.","severity":"deprecated","affected_versions":"<5.5.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Install globally using `npm install -g bash-language-server` or ensure your PATH includes the npm global bins (e.g., `export PATH=\"$(npm config get prefix)/bin:$PATH\"`).","cause":"The package is not installed globally or the npm global bin directory is not in your system's PATH.","error":"bash-language-server: command not found"},{"fix":"Upgrade Node.js to version 16 or higher. Using `nvm` is recommended: `nvm install 18 && nvm use 18`.","cause":"The installed Node.js version does not meet the minimum requirement of Node.js 16 or higher.","error":"Error: Node.js version too old. Expected >=16. Got 14.x.y"},{"fix":"Verify global installation with `bash-language-server --help` in your terminal and ensure the npm global bin directory is correctly configured in your system's PATH, especially for the environment your editor runs in.","cause":"Your editor's LSP client cannot locate or execute the `bash-language-server` binary.","error":"[LSP Error] Failed to start bash-language-server. Make sure it's installed and executable."}],"ecosystem":"npm"}