question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find module 'socket.io'

See original GitHub issue

Hello,

I’m receiving the error Cannot find module socket.io when I try to start the mqtt panel even I installed socket.io via npm -g install socket.io

Any idea how to get rid of this error? Here you are the full error message:

module.js:472
    throw err;
    ^

Error: Cannot find module 'socket.io'
    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> (/etc/mqtt-panel/server.js:8: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)

Thanks in Advance, Thomas

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
otrabcommented, Apr 21, 2017

Hi @tringler I think you use bad the mqtt method

check this https://github.com/mqttjs/MQTT.js/blob/master/examples/client/simple-both.js

whit this I can run ./runner.sh

0reactions
falkTXcommented, Mar 9, 2018

The current change makes it work for me:

diff --git a/server.js b/server.js
index 4af2095..96838e7 100644
--- a/server.js
+++ b/server.js
@@ -9,10 +9,10 @@ var socket = require('socket.io');
 //var firmata = require('firmata');
 
 var mqttbroker = 'localhost';
-var mqttport = 1883;
+var mqttport = '1883';
 
 var io = socket.listen(3000);
-var mqttclient = mqtt.createClient(mqttport, mqttbroker);
+var mqttclient = mqtt.connect('tcp://' + mqttbroker + ':' + mqttport);
 
 // Subscribe to topic
 io.sockets.on('connection', function (socket) {
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Cannot find module 'socket.io' - node.js - Stack Overflow
In first case, I tried adding the socket.io path in global path variable but it did not work. Share.
Read more >
Cannot find module 'socket.io' error in Node.js [Solved]
The error "Cannot find name 'socket.io'" occurs when we import the socket.io module before installing it. To solve the error, install the socket.io...
Read more >
socket.io - npm
Socket.IO enables real-time bidirectional event-based communication. It consists of: a Node.js server (this repository); a Javascript client ...
Read more >
Error: Cannot find module 'socket.io' · Issue #1258 - GitHub
NodeJS is server side, not Javascript browser client side. (https://github.com/socketio/socket.io). Close ticket?
Read more >
why can't i find the module 'socket.io'? - Google Groups
i have installed the module 'socket.io' currectly in 'C:\Documents and. Settings\xxx\node_modules'. and i have checked that i can require the module ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found