Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

339
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda