Node-rdkafka: Unable to compile in Angular 6

Created on 23 May 2018  Â·  1Comment  Â·  Source: Blizzard/node-rdkafka

Environment Information

  • OS [e.g. Mac, Arch, Windows 10]: OSX 10.13.4
  • Node Version [e.g. 8.2.1]: 10.1.0
  • NPM Version [e.g. 5.4.2]: 5.6.0
  • C++ Toolchain [e.g. Visual Studio, llvm, g++]: g++
  • node-rdkafka version [e.g. 2.3.3]: 2.3.3

Steps to Reproduce
I attached here a short Angular 6 project. Here is the instruction how to re-produce the issue:
poc-kafka-typescript.zip

  1. Install NodeJs 10.1.0
  2. Install Angular CLI by running: npm install -g @angular/cli
  3. extract the attached zip file
  4. cd poc-kafka-typescript
  5. npm install
  6. ng serve --open

You will get this log in command line:

** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

Date: 2018-05-23T04:54:39.511Z
Hash: 11353a5e57a0e9be836e
Time: 2817ms
chunk {main} main.js, main.js.map (main) 1.96 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 695 bytes [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 5.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 15.6 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 325 kB [initial] [rendered]

ERROR in node_modules/node-rdkafka/index.d.ts(1,36): error TS2307: Cannot find module 'stream'.
node_modules/node-rdkafka/index.d.ts(5,29): error TS2552: Cannot find name 'NodeJS'. Did you mean 'Node'?
node_modules/node-rdkafka/index.d.ts(174,10): error TS2304: Cannot find name 'Buffer'.

ℹ 「wdm」: Failed to compile.

node-rdkafka Configuration Settings
'localhost', '9092', 'hello-world-group'

Additional context
we use "kafka-typescript" library which, in turn, uses node-rdkafka

Most helpful comment

Hi!

You won't be able to connect to Kafka from a web browser. You'll need a backend system in place that your angular app can communicate with, and that system can connect to Kafka. The kafka-typescript library is intended for use in Node.js applications, not Angular applications.

>All comments

Hi!

You won't be able to connect to Kafka from a web browser. You'll need a backend system in place that your angular app can communicate with, and that system can connect to Kafka. The kafka-typescript library is intended for use in Node.js applications, not Angular applications.

Was this page helpful?
0 / 5 - 0 ratings