Mqtt.js: Error: Cannot find module './bin/pub'

Created on 18 Jun 2020  Â·  7Comments  Â·  Source: mqttjs/MQTT.js

I am trying to run the code:

mqtt sub -t 'hello' -h 'test.mosquitto.org' -v

But I am getting the following error:

Error: Cannot find module './bin/pub'

The issue goes away when I change the require from ./bin/pub to ./pub
The same thing happens to require('./bin/sub').

Here is the full error message:

PS C:\Users\MNunes\mqtt_react-test> mqtt pub -t 'hello' -h 'test.mosquitto.org' -m 'from MQTT.js'
internal/modules/cjs/loader.js:1032
  throw err;
  ^

Error: Cannot find module './bin/pub'
Require stack:
C:\Users\MNunes\AppData\Roaming\npm\node_modules\mqtt\bin\mqtt.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15)
    at Function.Module._load (internal/modules/cjs/loader.js:898:27)
    at Module.require (internal/modules/cjs/loader.js:1089:19)
    at require (internal/modules/cjs/helpers.js:73:18)
    at Object.<anonymous> (C:\Users\MNunes\AppData\Roaming\npm\node_modules\mqtt\bin\mqtt.js:14:29)
    at Module._compile (internal/modules/cjs/loader.js:1200:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\MNunes\\AppData\\Roaming\\npm\\node_modules\\mqtt\\bin\\mqtt.js'
  ]
}

Is it supposed to work with require('./bin/pub') ?
If yes, could you explain if I have done something wrong?

Most helpful comment

me too bro,

C:\Users\password-123>mqtt -v
internal/modules/cjs/loader.js:969
throw err;
^

Error: Cannot find module './bin/pub'
Require stack:

  • C:\Users\password-123\AppData\Roaming\npm\node_modules\mqtt\bin\mqtt.js
     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
     at Function.Module._load (internal/modules/cjs/loader.js:842:27)
     at Module.require (internal/modules/cjs/loader.js:1026:19)
     at require (internal/modules/cjs/helpers.js:72:18)
    at Object. (C:\Users\password-123\AppData\Roaming\npm\node_modules\mqtt\bin\mqtt.js:14:29)
     at Module._compile (internal/modules/cjs/loader.js:1138:30)
     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
     at Module.load (internal/modules/cjs/loader.js:986:32)
     at Function.Module._load (internal/modules/cjs/loader.js:879:14)
     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    'C:\Users\password-123\AppData\Roaming\npm\node_modules\mqtt\bin\mqtt.js'
    ]
    }

All 7 comments

Just noticed there is a fix for this - https://github.com/mqttjs/MQTT.js/pull/1107
I will wait for the next release. Thanks!

me too bro,

C:\Users\password-123>mqtt -v
internal/modules/cjs/loader.js:969
throw err;
^

Error: Cannot find module './bin/pub'
Require stack:

  • C:\Users\password-123\AppData\Roaming\npm\node_modules\mqtt\bin\mqtt.js
     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
     at Function.Module._load (internal/modules/cjs/loader.js:842:27)
     at Module.require (internal/modules/cjs/loader.js:1026:19)
     at require (internal/modules/cjs/helpers.js:72:18)
    at Object. (C:\Users\password-123\AppData\Roaming\npm\node_modules\mqtt\bin\mqtt.js:14:29)
     at Module._compile (internal/modules/cjs/loader.js:1138:30)
     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
     at Module.load (internal/modules/cjs/loader.js:986:32)
     at Function.Module._load (internal/modules/cjs/loader.js:879:14)
     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    'C:\Users\password-123\AppData\Roaming\npm\node_modules\mqtt\bin\mqtt.js'
    ]
    }

I just installed it from npm. The bug still exists.

I use v4.0.0 until the next release.

npm install -g [email protected]

confused why the changes are not in the release...

oh we just haven't released yet. Keeping open till next release goes out.

thank for your kindness :-D

On Wed, Jul 29, 2020 at 11:51 PM Yoseph Maguire notifications@github.com
wrote:

oh we just haven't released yet. Keeping open till next release goes out.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/mqttjs/MQTT.js/issues/1113#issuecomment-665793908,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AKRNYNIOPUYFPMBMDXGOZKTR6BLADANCNFSM4OB7L3SQ
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

goliatone picture goliatone  Â·  4Comments

SSL
reejinbouk picture reejinbouk  Â·  4Comments

helxsz picture helxsz  Â·  3Comments

sueblue picture sueblue  Â·  6Comments

ysfscream picture ysfscream  Â·  5Comments