-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to import #8
Comments
@link2malkeet Please provide a minimal, complete and verifiable example for your issue, as they're both valid exports, they can work side-by-side in CommonJS and ES6 environments, and the latest beta version has been verified to work. To verify yourself —
|
HI @paambaati Just to summarize what I know or understand, the main index file works with default exports only, we don't need to define module.exports in typescript. Thanks |
Hi @paambaati Just following up on this, is the beta version going to be promoted? |
@AlanKavanagh Can you confirm the beta version works for you? It'd be great if you can tell us a little about your Kafka cluster and how long you've been using the beta version. |
I have the same problem, I'm getting TypeError: LZ4Codec is not a constructor
at Object.<anonymous> (/xxx/public/server/controller/kafka.js:13:21)
at Module._compile (node:internal/modules/cjs/loader:1116:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1169:10)
at Module.load (node:internal/modules/cjs/loader:988:32)
at Module._load (node:internal/modules/cjs/loader:829:12)
at Function.c._load (node:electron/js2c/asar_bundle:5:13343)
at Module.require (node:internal/modules/cjs/loader:1012:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/xxx/public/server/controller/consumer.js:1:15)
at Module._compile (node:internal/modules/cjs/loader:1116:14)
npm run electron:start exited with code 7 I'm doing an electron app. On the server side I have const { Kafka, CompressionTypes, CompressionCodecs } = require("kafkajs");
const { LZ4Codec } = require('kafkajs-lz4');
const username = "nope";
const password = "nope";
const sasl =
username && password ? { username, password, mechanism: "plain" } : null;
const ssl = !!sasl;
// LZ4 compression
const LZ4Instance = new LZ4Codec()
CompressionCodecs[CompressionTypes.LZ4] = LZ4Instance.codec;
const kafka = new Kafka({
clientId: "noper",
brokers: ["nope"],
ssl,
sasl,
});
module.exports = kafka; Then const kafka = require("./kafka");
const io = require("../socket");
const consumer = async (topic) => {
const consumer = kafka.consumer({ groupId: "test-group" });
try {
await consumer.connect();
} catch (e) {
console.log("Error: couldn't connect to Kafka");
return;
}
console.log("Connected to Kafka!");
try {
await consumer.subscribe({ topic, topic });
} catch (e) {
console.log("Error: couldn't subscribe to topic.");
return;
}
console.log("Kafka consumer subscribed.");
console.log("Consuming...");
try {
await consumer.run({
eachMessage: async ({ topic, partition, message }) => {
console.log("Received message: " + message.value.toString());
io.getIO().emit("events", {
action: "consume",
event: message.value.toString(),
});
},
});
} catch (e) {
console.log("Couldn't consume message");
}
};
module.exports = consumer; I hope this helps narrow it down somehow. Ask if you need more specific info. |
I see below error as well:
when using:
|
Seems you have mixed the default import vs module.export.
export default class LZ4Codec
vs
module.exports = LZ4Codec;
So unable to use the library.
Can we please fixed it?
The text was updated successfully, but these errors were encountered: