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.
VueHighlightJS
✓ import VueHighlightJS from 'vue-highlight.js'
✗ const VueHighlightJS = require('vue-highlight.js')
Default ESM import. CommonJS require may work but ESM recommended.
VueHighlightJS (via component)
✓ Vue.use(VueHighlightJS)
✗ Vue.component('highlightjs', VueHighlightJS)
Must call Vue.use() to register the component globally with default name 'highlightjs'.
languages
✓ import 'vue-highlight.js/lib/languages/vue'
✗ import VueHighlightJS from 'vue-highlight.js'
Languages must be imported separately after v3.0.0. This imports the Vue language definition.
allLanguages
✓ import 'vue-highlight.js/lib/allLanguages'
✗ import VueHighlightJS from 'vue-highlight.js'
Import all languages from highlight.js. Only available since v3.1.0.
Install and use the plugin with Vue 2, importing custom languages and rendering a highlighted code block.
import Vue from 'vue';
import VueHighlightJS from 'vue-highlight.js';
import 'vue-highlight.js/lib/languages/javascript';
import 'vue-highlight.js/lib/languages/css';
Vue.use(VueHighlightJS);
new Vue({
el: '#app',
template: '<highlightjs code="console.log(\'hello\')" lang="javascript" />'
});
Errors
Common errors & fixes
Unknown custom element: <highlightjs> - did you register the component correctly?
Component not registered globally because Vue.use() was not called or was called incorrectly.
fixCall Vue.use(VueHighlightJS) before creating the Vue instance.
Cannot find module 'vue-highlight.js/lib/languages/vue'
Language path incorrect or language not installed. Ensure you are importing from the correct path.
fixUse correct path: import 'vue-highlight.js/lib/languages/vue'
highlight.js is not defined
highlight.js peer dependency not installed.
fixRun: npm install highlight.js@^9.11.0
Audit
Dependencies
vuerequiredpeer dependency for Vue 2
highlight.jsrequiredpeer dependency for syntax highlighting library