Registry / web-framework / unified-language-server

unified-language-server

JSON →
library4.0.1jsnpmunverified

unified-language-server provides a framework for building language servers based on the unified ecosystem. It allows developers to create editor integrations that format and validate documents using existing unified processors like remark (for Markdown) or rehype (for HTML). The current stable version is 4.0.1, with minor releases typically focusing on dependency updates and bug fixes, and major versions introducing breaking changes such as Node.js version requirements or significant internal refactors (e.g., using `unist-util-lsp`). Key differentiators include its tight integration with `unified-engine` for configuration file support (like `.remarkrc`) and its ability to work with any unified processor, simplifying the creation of LSP-compliant tools for AST transformations. It supports features like document formatting, validation, and quick fixes.

npm install unified-language-server
INSTALL
IMPORT
SIG · UNIFIED-LANGUAGE-S
U
unified-language-server
web-frameworkjavascriptv4.0.1
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createUnifiedLanguageServer
✓ import { createUnifiedLanguageServer } from 'unified-language-server'
✗ const { createUnifiedLanguageServer } = require('unified-language-server')
Package is ESM-only since v3.0.0, requiring `import` syntax and a Node.js `type: "module"` package configuration.
remark
✓ import { remark } from 'remark'
✗ import remark from 'remark'
The `remark` package exports its processor as a named export, not a default export.
LanguageServerOptions
✓ import type { LanguageServerOptions } from 'unified-language-server'
✗ import { LanguageServerOptions } from 'unified-language-server'
TypeScript type import. Use `import type` to ensure it's not bundled as runtime code, especially if configuring a language server in TypeScript.

Demonstrates how to create a basic language server for `remark` using `unified-language-server`, including configuration options for file handling.

import { remark } from 'remark'; import { createUnifiedLanguageServer } from 'unified-language-server'; // Set the process title for easier identification in system monitors process.title = 'my-remark-language-server'; // Create and start the language server createUnifiedLanguageServer({ // Name of ignore files (e.g., '.remarkignore') ignoreName: '.remarkignore', // Field in package.json to look for configuration packageField: 'remarkConfig', // Prefix for plugin names (e.g., 'remark-lint-') pluginPrefix: 'remark', // Name of the RC file (e.g., '.remarkrc') rcName: '.remarkrc', // The package ID of the expected processor (e.g., 'remark') processorName: 'remark', // The specifier to get the processor on the resolved module (e.g., 'remark' for named export) processorSpecifier: 'remark', // Optional fallback processor if `processorName` isn't found locally defaultProcessor: remark }); console.log('Remark language server started. Waiting for client connection...');
unified-language-server --version
Debug
Known issues
breakingSupport for Node.js 12 was removed. Ensure your environment runs Node.js 16.0 or higher.
fix
Upgrade your Node.js runtime to version 16.0 or newer.
affects: >=3.0.0
breakingThe package transitioned to ESM-only. CommonJS `require()` is no longer supported for importing `unified-language-server`.
fix
Update imports to use `import` statements and ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json`).
affects: >=3.0.0
breakingUpdated `unified-engine` dependency, which notably introduced support for YAML 1.2 in configuration files. This might affect how existing configuration files are parsed if they rely on older YAML features or if new YAML 1.2 syntax is introduced.
fix
Review existing configuration files (`.remarkrc`, etc.) to ensure compatibility with `unified-engine`'s updated YAML parser. Update YAML configurations if necessary.
affects: >=3.0.0
breakingRefactored to use `unist-util-lsp` internally. While not a direct API change for most users, this signals significant internal architecture updates which could affect custom extensions or deep integrations.
fix
No direct fix needed for standard usage. If you have custom extensions interacting with internal structures, verify compatibility or consult the `unist-util-lsp` documentation.
affects: >=4.0.0
gotchaIf `options.processorName` cannot be found locally in `node_modules`, a warning is shown. This can happen if the processor (e.g., `remark`) is not installed as a dependency in the workspace where the language server is running.
fix
Always ensure that the `processorName` specified (e.g., `remark`) is correctly listed and installed as a dependency in your language server's `package.json` or the user's project `node_modules`.
affects: >=1.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM
Attempting to `require()` an ESM-only package.
fix
Change `const { createUnifiedLanguageServer } = require('unified-language-server');` to `import { createUnifiedLanguageServer } from 'unified-language-server';` and ensure `"type": "module"` is set in your `package.json`.
Error: Cannot find module 'remark' from '/path/to/language-server'
The specified `processorName` (e.g., 'remark') is not installed in the environment where the language server is executing.
fix
Ensure the processor package (e.g., `remark`) is listed in your language server's `dependencies` and run `npm install`.
TypeError: options.defaultProcessor is not a function
`defaultProcessor` was passed an incorrect value or the imported processor is not the expected `unified` function.
fix
Verify that `defaultProcessor` receives a valid `unified` processor instance (e.g., `remark`) and that its named export is correctly imported (e.g., `import { remark } from 'remark';`).
Language server failed to initialize: Configuration option 'requireConfig' is not recognized.
Using an outdated client or language server definition that doesn't recognize newer configuration options.
fix
Ensure both the `unified-language-server` package and the editor client integration are updated to their latest versions to support all configuration features.
Upgrade
Version history
4.0.1latest on npm
Audit
Dependencies
unified-enginerequiredCore dependency for processing multiple files with unified and handling configuration files.
unist-util-lsprequiredUsed internally since v4.0.0 for Language Server Protocol utilities related to unist ASTs.
remarkoptionalCommonly used as the default processor example; developers will typically depend on a specific unified processor.
Agent activity
5 hits · last 30 days
node
4
Resources
unified-language-server — npm install unified-language-server · libregistry