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

192
Views
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 answers
Answer question

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 Report
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!