I have installed 'node.js' and then executed 'npm install mqtt' from 'node.js' command line to install 'mqtt.js'. Now to test 'mqtt client' I am trying to execute : var mqtt = require('mqtt'); which results in error saying:
"Error: Cannot find module 'mqtt'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at repl:1:12
at REPLServer.self.eval (repl.js:110:21)
at repl.js:249:20
at REPLServer.self.eval (repl.js:122:7)
at Interface.<anonymous> (repl.js:239:12)
at Interface.EventEmitter.emit (events.js:95:17)"
First, you need to add the MQTT library.
If you have npm package manager installed on the server, you should run npm install mqtt --save
For detailed information: https://www.npmjs.com/package/mqtt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With