throw err无法找到模块'node-rdkafka'

时间:2017-12-27 22:16:04

标签: node.js apache-kafka

我在MacBook Pro上使用“npm install node-rdkafka”命令安装了node-rdkafka。 然后,我试图在Eclipse中构建以下node.js代码,但是观察到以下抛出错误。

在Eclipse Node.JS应用程序中,

var Kafka = require('node-rdkafka');
var producer = new Kafka.Producer({
      'metadata.broker.list': 'localhost:9092',
      'dr_cb': true
    });

观察到构建错误:

module.js:471
    throw err;
    ^

Error: Cannot find module 'node-rdkafka'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/pparasuraman/eclipse-workspace/NodeProject1/server.js:5:13)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

有人可以帮我解决这个错误,因为我找不到解决方法吗?

1 个答案:

答案 0 :(得分:1)

在您的终端

cd /Users/pparasuraman/eclipse-workspace/NodeProject1
npm install --save node-rdkafka