Kafka-node

I’ve manage to include kafka-node in my Ionic2 app:

import {Client}  from 'kafka-node';
...
export class Service {
    public kafkaclient: any;
    constructor(){
        this.kafkaclient = new Client("localhost:2181","kafka-client-id");
...

However calling new Client(...) causes app.bundle.js to throw an error saying it can’t load module ./lib/BufferMaker

I’ve tried a bunch of things like explicitly listing buffermaker as a dependency in package.json, however nothing seems to work. I’m thinking it has something to do with how Ionic2 uses browserify.

Any idea how to fix this?

Did you declare anything in app.module.ts ???

No I didn’t. Was I meant to?

I since found the problem that some node modules were using dynamic requires, which browserify does not detect. When I changed these then it fixed the above problem.

However now I have the problem that net.connect is not available in Ionic, it is rather a node built in of some kind.

Ah, you are using Browserify. And yes, the Net module is Node Core. I’m not sure if there is a way to wrap it up to use in-app…

Hey, did you ever get Kafka working with your Ionic application? I am looking to make an application that does the same thing.