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.
vitePluginMdToHTML
✓ import { vitePluginMdToHTML } from 'vite-plugin-md-to-html'
✗ import vitePluginMdToHTML from 'vite-plugin-md-to-html'
Named export, not default. TypeScript types are included.
attributes
✓ import { attributes } from './test.md'
✗ import attributes from './test.md'
attributes is a named export from the compiled markdown module. Default export is the HTML string.
PluginOptions
✓ import type { PluginOptions } from 'vite-plugin-md-to-html'
TypeScript only; available since v0.0.14.
Shows Vite plugin setup with image resolution and syntax highlighting, plus importing .md to get HTML string and frontmatter attributes.
// vite.config.ts
import { defineConfig } from 'vite';
import { vitePluginMdToHTML } from 'vite-plugin-md-to-html';
export default defineConfig({
plugins: [
vitePluginMdToHTML({
resolveImageLinks: true,
syntaxHighlighting: true
})
]
});
// src/main.ts
import html, { attributes } from './test.md';
document.title = attributes.title ?? '';
document.querySelector('#app')!.innerHTML = html;
type Frontmatter = {
title?: string;
// ... other fields
};
Errors
Common errors & fixes
Cannot find module './test.md' or its corresponding type declarations.
TypeScript cannot resolve .md imports without a type declaration.
fixAdd `/// <reference types='vite-plugin-md-to-html/types' />` to a global.d.ts file.
[vite] Internal server error: Failed to parse source for import analysis because the content contains invalid JS syntax.
Vite fails to parse .md file if the plugin is not properly configured in config.
fixEnsure the plugin is added to the vite.config.js/ts plugins array.
Uncaught TypeError: Failed to resolve module specifier 'vite-plugin-md-to-html'. Relative references must start with either '/', './', or '../'.
The package is not installed or not imported correctly.
fixRun `npm install --save-dev vite-plugin-md-to-html` and verify import path.
Audit
Dependencies
viterequiredpeer dependency; plugin only works with Vite
markdown-itrequiredcore markdown parser used internally
highlight.jsoptionalused for syntax highlighting when option enabled