throw err Cannot find module 'node-rdkafka' - node.js

I have installed node-rdkafka using "npm install node-rdkafka" command on MacBook Pro.
Then, I am trying to build the following node.js code in Eclipse, but observing the following throw error.
In Eclipse Node.JS application,
var Kafka = require('node-rdkafka');
var producer = new Kafka.Producer({
'metadata.broker.list': 'localhost:9092',
'dr_cb': true
});
Build Error observed:
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)
Could someone please help me to solve this error, as I couldn't find a way to fix it?

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

Related

Debugging Gulp Build failure via SmartAdmin project

I'm fairly new to Node JS, and trying to run gulp build to compile my project from a theme I bought. I've tried googling my issue and not having any luck really on what I need to look for. If someone could help me out with what I should be looking for or even know what the issue is.
Here is the error I'm getting, and this is from the smartadmin theme on wrapbootstrap.
When I get through all the processes of setup in html-seed directory, it's throwing this error.
PS C:\Users\Kevin Carson\Desktop\smartadmin-html-seed> gulp build module.js:471
throw err;
^
Error: Cannot find module 'require-dir'
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> (C:\Users\Kevin Carson\Desktop\smartadmin-html-seed\gulpfile.js:3:18)
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)
Looks like it it can't find a package. Run npm install from the same directory as your package.json to install the packages.

What is module.js 540 throw error?

Just installing node/npm first time, Linux Fedora: I've followed all the instructions and tried every fix I can find on google.
Whenever I try to run npm install or npm test I get this:
module.js:540
throw err;
^
Error: Cannot find module 'npmlog'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at /usr/lib/node_modules/npm/bin/npm-cli.js:22:13
at Object.<anonymous> (/usr/lib/node_modules/npm/bin/npm-cli.js:92:3)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
It was a bug and it has already been fixed in Node v5.4.1. Now it's working as usual.

Updating node.js possibly lead to npm error

I recently updated the node.js to the version 6.11.1. Got an error when accessing npm
When I tried to check the version of npm, the following error occurs
$ npm -v
module.js:471
throw err;
^
Error: Cannot find module '../lib/utils/unsupported.js'
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 C:\Users\dino\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js:19:21
at Object.<anonymous> (C:\Users\dino\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js:92:3)
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)
After getting this error I updated the node.js to the latest version 8.1.4.
and the error is same with different line numbers.
$ npm -v
module.js:487
throw err;
^
Error: Cannot find module '../lib/utils/unsupported.js'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at C:\Users\dino\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js:19:21
at Object.<anonymous> (C:\Users\dino\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js:92:3)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
What is happening? Any fix to this issue?
At last, I got the solution.
I have copied all contents from
C:\Program Files\nodejs\node_modules\npm
and pasted it in
C:\Users\dino\AppData\Roaming\npm\node_modules\npm

Error while creating new nodejs project in Netbeans

I have installed express globally and also ran npm update -g and I can create express app using terminal without problems. But when I create a new nodejs project in Netbeans 8.2 I get these errors :
module.js:472
throw err;
^
Error: Cannot find module 'mkdirp'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/bin/express:10:14)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
Can someone help me integrate Expressjs properly with netbeans please? Thanks in advance.
[UPDATE]
I figured there is something wrong in the Node path in Netbeans. Can someone tell me what do I add here for Ubuntu :

the command "npm" returns with an error

*
C:\Users\xxxxx>npm
module.js:471
throw err;
^
Error: Cannot find module 'semver'
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. >(C:\Users\xxxxx\AppData\Roaming\npm\node_modules\npm\lib\utils\unsupported.js:2:>14)
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)
C:\Users\xxxxx>
It's saying that it cannot find the module semver.
Try running npm install semver --save
Try running npm install semver --save in your console under current directory where you are starting the node app.
npm install semver --save
works.

Resources