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
muslnode 18–223 runs
build_error
glibcnode 18–223 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
YAMLPlugin
✓ import { YAMLPlugin } from 'esbuild-yaml'
✗ const YAMLPlugin = require('esbuild-yaml')
ESM-only package; CommonJS require not supported.
YAMLPlugin
✓ const { YAMLPlugin } = await import('esbuild-yaml')
✗ const { YAMLPlugin } = require('esbuild-yaml')
Dynamic import works in CommonJS modules with top-level await.
type YAMLPluginOptions
✓ import type { YAMLPluginOptions } from 'esbuild-yaml'
✗ import { YAMLPluginOptions } from 'esbuild-yaml'
Use 'import type' for type-only imports to avoid runtime errors.
Shows how to use YAMLPlugin with esbuild to import YAML files as objects.
import { build } from 'esbuild';
import { YAMLPlugin } from 'esbuild-yaml';
build({
entryPoints: ['src/index.ts'],
outfile: 'dist/bundle.js',
bundle: true,
plugins: [YAMLPlugin()],
}).catch(() => process.exit(1));
// Then in src/index.ts:
// import config from './config.yaml';
// console.log(config); // { name: "esbuild-yaml", version: "1.0.0" }
Errors
Common errors & fixes
Error: Cannot find module 'esbuild-yaml'
The package is not installed or is a dev dependency not available at runtime.
fixRun 'npm install --save-dev esbuild-yaml esbuild' to install as dev dependency.
TypeError: YAMLPlugin is not a constructor
Trying to use YAMLPlugin without calling it as a function (e.g., plugins: [YAMLPlugin] instead of plugins: [YAMLPlugin()])
fixUse YAMLPlugin() in the plugins array.
Module not found: Error: Can't resolve './file.yaml'
YAMLPlugin is not loaded or not properly configured in the esbuild build.
fixEnsure the YAMLPlugin is added to the plugins array in esbuild's build options.
node:internal/modules/cjs/loader:1078 - throw err; Error: Cannot find module 'yaml'
The 'yaml' peer dependency is missing.
fixInstall yaml: npm install yaml (or ensure it is included via esbuild-yaml's dependencies).
Audit
Dependencies
esbuildrequiredPeer dependency required to use esbuild plugins
yamlrequiredRuntime dependency for parsing YAML files