Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

340
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda