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.
default
✓ import i18nLoaderPlugin from 'vite-i18n-by-design';
✗ import { i18nLoaderPlugin } from 'vite-i18n-by-design';
Default export only; named export does not exist.
virtual:i18n-messages
✓ import messages from 'virtual:i18n-messages';
Virtual module provided by the plugin; must be used with Vite. Type declarations included in package.
loadMessages
✓ import { loadMessages } from 'vite-i18n-by-design';
✗ import loadMessages from 'vite-i18n-by-design';
Named export for Node.js script usage; not suitable for browser or HMR.
Configures the Vite plugin, creates a vue-i18n instance with virtual messages, and mounts the app.
// vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import i18nLoaderPlugin from 'vite-i18n-by-design'
export default defineConfig({
plugins: [
vue(),
i18nLoaderPlugin({ localesDir: 'locales' })
]
})
// src/i18n.ts
import { createI18n } from 'vue-i18n'
import messages from 'virtual:i18n-messages'
export const i18n = createI18n({
legacy: false,
locale: 'fr',
fallbackLocale: 'en',
messages
})
// main.ts
import { createApp } from 'vue'
import { i18n } from './i18n'
import App from './App.vue'
createApp(App).use(i18n).mount('#app')
Errors
Common errors & fixes
Cannot find module 'virtual:i18n-messages' or its corresponding type declarations.
TypeScript does not recognize the virtual module by default.
fixAdd the provided .d.ts file to your tsconfig include array, or use a path mapping.
Error: Cannot find module 'yaml'
YAML dependency not installed when using YAML files.
fixInstall yaml: npm install yaml
TypeError: Messages must be an object or a function that returns an object.
Invalid message structure after merging; likely nested incorrectly.
fixEnsure each locale folder contains namespace files (e.g., locales/en/app.json), not direct message files.
Audit
Dependencies
vue-i18nrequiredThe plugin generates messages for vue-i18n; must be installed in the project.
yamloptionalUsed internally to parse YAML files. Not a peer dependency, but may need to be installed if not already available.