Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

334
Views
The highlight.js works perfectly locally - on web server it doesn't work at all (no console issues)

This is very bizarre as I have a mismatch in behaviour of highlight.js.

This is how I install it:

npm install highlight.js

This is how I initialize it:

import hljs from 'highlight.js/lib/core';

// Particular languages
import bash from 'highlight.js/lib/languages/bash';
import css from 'highlight.js/lib/languages/css';
import javascript from 'highlight.js/lib/languages/javascript';
import php from 'highlight.js/lib/languages/php';
import phpTemplate from 'highlight.js/lib/languages/php-template';
import scss from 'highlight.js/lib/languages/scss';
import xml from 'highlight.js/lib/languages/xml';
import yaml from 'highlight.js/lib/languages/yaml';

hljs.registerLanguage('bash', bash);
hljs.registerLanguage('css', css);
hljs.registerLanguage('javascript', javascript);
hljs.registerLanguage('php', php);
hljs.registerLanguage('phpTemplate', phpTemplate);
hljs.registerLanguage('scss', scss);
hljs.registerLanguage('xml', xml);
hljs.registerLanguage('yaml', yaml);

// Chosen style (https://highlightjs.org/static/demo/)
import 'highlight.js/styles/github.css';

// Init
hljs.highlightAll();

Lastly I run npm run dev or npm run production. All good. No issues.

Finally when I have a page with <code> and <pre>, the library works perfectly on my local docker and adds its classes.

enter image description here

  • Local docker highlight.js version: ^11.3.1
  • Local docker npm version: 6.14.14
  • Local docker node version: v12.22.5

Now I have the same website deployed on my server and the code is not highlighted.

enter image description here

There are no issues during npm run production. No issues in the console. No issues printed anywhere. Literally this is the same codebase.

  • Server highlight.js version: ^11.3.1
  • Server npm version: 6.14.8
  • Server node version: v14.15.0

The only major difference is in node. Server has v14, local docker has v12 but server doesn't show any issues when I build everything.

Can I get any hints what went wrong?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!