Hi,
I have a simple JavaScript programm with NodeJS that sends messages to Rabbitmq.
I want to make this into an executable but this doesn´t work.
I´ve tried pkg and nexe but both don´t work with any node version above node14.
And when I tried it with node14 the dependencies for amqplib were not working since I got an error with this line:
const connection = await connect('amqp://localhost');
My JavaScript file looks like this:
import { connect } from 'amqplib';
const message = process.argv.slice(2).join(' ');
async function sendMessage(message) {
const connection = await connect('amqp://localhost');
const channel = await connection.createChannel();
const queue = 'messages';
await channel.assertQueue(queue, { durable: false});
channel.sendToQueue(queue, Buffer.from(message));
setTimeout(() => {
console.log(' [x] Sent: ' + message);
connection.close();
}, 100);
}
And my package.json has these dependencies:
"dependencies": {
"amqplib": "^0.10.3",
"express": "^4.19.2"
}
So if anyone managed to make an executable that can send messages to Rabbitmq please tell me how.