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

193
Visualizações
How to use a third party library in nodejs

I am trying to setup a webserver that is able to send messages to a message queue. For this, I want to use STOMPIT. I have setup a basic nodejs webserver with an index.html, main.js and app.js but can't get the stompit library working in my main.js.

How can I use the library (imported with the script tags in the html) in my main.js?

Parts of the code: index.html:

<script src="https://cdnjs.cloudflare.com/ajax/libs/stomp.js/2.3.3/stomp.js"></script>
<script src="js/main.js"></script>

main.js:

    stompit.connect(connectOptions, function(error, client) { //stompit is undefined here

        if (error) {
            console.log('connect error ' + error.message);
            return;
        }

        const sendHeaders = {
            'destination': '/queue/test',
            'content-type': 'text/plain'
        };

        const frame = client.send(sendHeaders);
        frame.write(msg);
        frame.end();
    })
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You have to choose a module on npmjs.com, install it and use it in your scripts. For example with stomp module (there are others on npmjs) : https://www.npmjs.com/package/stompjs

Install it with:

npm install --save stompjs

Import it in your scripts:

const Stomp = require('stompjs');

You can find other details about using it on: https://www.npmjs.com/package/stompjs

about 4 years ago · Juan Pablo Isaza Relatório
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