The Svelte Language Server (package `svelte-language-server`, currently at version 0.17.30) provides language-specific smarts for Svelte development within various editors by implementing the Language Server Protocol (LSP). It acts as the core engine for features like diagnostics, autocompletion, hover information, formatting, and code actions for Svelte, HTML, CSS/SCSS/LESS, and TypeScript/JavaScript within Svelte components. It is an actively maintained component of the broader `sveltejs/language-tools` monorepo, with frequent patch releases addressing performance improvements and bug fixes, typically on a weekly or bi-weekly cadence. Key differentiators include its deep integration with the Svelte compiler and TypeScript, leveraging `svelte2tsx` for seamless type-checking, and its ability to provide comprehensive language features across multiple embedded languages within `.svelte` files. Unlike many libraries consumed directly via `import`, this package is primarily designed to be run as a separate process by editor extensions (like the official VS Code Svelte extension) or custom LSP clients, offering a robust and extensible foundation for Svelte tooling. Its current stable versions require Node.js >= 18.0.0.
npm install svelte-language-serverVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to launch the Svelte Language Server as a child process and send an `initialize` request, illustrating basic programmatic interaction for building an LSP client.
Upgrade your Node.js environment to version 18.0.0 or higher.
Refer to the official documentation for `svelte-language-server` settings and the `svelte-vscode` extension settings for common configurations. Use the `initializationOptions.configuration` object for programmatic setup.
Ensure `typescript` is installed in your project's `devDependencies` (e.g., `npm install -D typescript@^5.0.0`) and that its version is compatible with the language server's requirements.
Configure `svelte.plugin.typescript.workspace.exclude` and similar options in your editor or language server initialization options. For CI/CD, use `svelte-check --incremental`.
Install TypeScript in your project: `npm install -D typescript` or `yarn add -D typescript`.
Check your Node.js version (must be >= 18.0.0). Inspect the server's `stderr` output for more specific error messages if available.
Update `svelte-language-server` to version `0.17.30` or newer, as this issue has been addressed in recent patches. Ensure your `tsconfig.json`'s `moduleResolution` is correctly configured.
Ensure `svelte.plugin.typescript.enable` is set to `true` in your language server configuration (e.g., editor settings). Verify your TypeScript installation and version.