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

194
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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