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–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
vitePluginMarkdown
✓ import markdownPlugin from 'vite-plugin-markdown'
✗ const markdownPlugin = require('vite-plugin-markdown');
Default import is the plugin function; commonjs require works only with v2, v3 is ESM only.
Mode
✓ import { Mode } from 'vite-plugin-markdown'
✗ import { Mode } from 'vite-plugin-markdown/modes'
Mode is a named export for configuration; use enum values like Mode.HTML, Mode.VUE, Mode.REACT, Mode.MARKDOWN.
use
✓ import { use } from 'vite-plugin-markdown'
✗ import use from 'vite-plugin-markdown'
The `use` function is a named export for use with Markdown component exports (e.g., in Vue or React); available since v2.
Configures the plugin with both Vue and HTML modes, then demonstrates importing rendered HTML and frontmatter from a markdown file.
// vite.config.js
import { defineConfig } from 'vite'
import markdownPlugin, { Mode } from 'vite-plugin-markdown'
export default defineConfig({
plugins: [
markdownPlugin({
mode: [Mode.VUE, Mode.HTML], // or Mode.REACT
}),
],
})
// Then in any .vue or .js file:
import { html, frontmatter } from './example.md'
console.log(html) // rendered HTML string
console.log(frontmatter) // parsed frontmatter object
// If using Mode.VUE, you can also import the Vue component:
import ExampleComponent from './example.md?component'
// If using Mode.MARKDOWN:
import raw from './example.md?raw' // or use Mode.MARKDOWN
Errors
Common errors & fixes
Cannot find module 'vite-plugin-markdown' or its corresponding type declarations.
Missing dependency or TypeScript not resolving types; package ships types but needs 'moduleResolution' set to 'bundler' or 'node16'.
fixRun `npm install --save-dev vite-plugin-markdown` and ensure tsconfig.json has `"moduleResolution": "bundler"`.
The requested module 'vite-plugin-markdown' does not provide an export named 'Mode'
Using named import `{ Mode }` with a CommonJS environment that doesn't support named exports.
fixUse default import `import markdownPlugin from 'vite-plugin-markdown'` and access `markdownPlugin.Mode`, or switch to ESM.
Error: Unsupported dynamic import: ./example.md?raw - consider using ?raw for raw markdown
Trying to import raw markdown but Mode.MARKDOWN not enabled in plugin config.
fixAdd Mode.MARKDOWN to the mode array in plugin configuration.
Audit
Dependencies
No dependency data recorded yet.