The current cpp highlighter is basically a redirection to c-like highlighter. If one registers this highlighter as in the documentation:
const hljs = require("highlight.js/lib/core");
// separately require languages
hljs.registerLanguage('cpp', require('highlight.js/lib/languages/cpp'));
const highlightedCode = hljs.highlight('cpp', 'cout << "Hello World!"').value
Without loading c-like highlighter first, the script above will throw an error.
If this behavior is intended, it should be mentioned in the documentation.