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.
jsonX
✓ import { jsonX } from 'vite-plugin-jsonx'
✗ import jsonX from 'vite-plugin-jsonx'
Named export (not default). The plugin only exports a named function.
plugin type
✓ import type { UserConfig } from 'vite'; import { jsonX } from 'vite-plugin-jsonx'; export default { plugins: [jsonX()] } satisfies UserConfig
✗ export default { plugins: [jsonX] }
Must call jsonX() (invoke function) to get plugin instance; passing the function without parentheses will break.
client types reference
✓ /// <reference types="vite-plugin-jsonx/client" />
✗ import 'vite-plugin-jsonx/client'
Add to env.d.ts for TypeScript ambient module declarations for .jsonc/.json5 imports. Improper import won't augment types.
Sets up the plugin in vite.config.ts with optional parser options, imports a .json5 file, and logs its property.
// vite.config.ts
import { defineConfig } from 'vite';
import { jsonX } from 'vite-plugin-jsonx';
export default defineConfig({
plugins: [
jsonX({
// optional: pass custom parser options
json5ParserOptions: { quote: 'double' },
jsoncParserOptions: { reviver: (key, value) => value }
})
]
});
// src/data.json5
{
name: 'Example',
version: 1.0,
// comment
}
// src/main.ts
import config from './data.json5';
console.log(config.name); // 'Example'
Errors
Common errors & fixes
[vite] Internal server error: Plugin must be an object.
Passing jsonX (function reference) instead of jsonX() in plugins array.
fixChange plugins: [jsonX] to plugins: [jsonX()].
Cannot find module './data.json5' or its corresponding type declarations.
Missing TypeScript ambient type declarations for .json5/.jsonc files.
fixAdd /// <reference types="vite-plugin-jsonx/client" /> to your env.d.ts file.
TypeError: jsonX is not a function
Incorrect import style (default import instead of named import).
fixUse import { jsonX } from 'vite-plugin-jsonx' (named import). Audit
Dependencies
viterequiredPeer dependency: Vite >=4.0.0 required for plugin compatibility.