MQTT.js icon indicating copy to clipboard operation
MQTT.js copied to clipboard

v5 Cannot be used in uniapp, app-plus environments

Open surge-squirrel opened this issue 1 year ago • 8 comments

as shown in the title

node 16 or 20 vue 2.6 mqtt 5.3.1

surge-squirrel avatar Nov 30 '23 05:11 surge-squirrel

What's the error you see? Is it on compilation time or runtime? What bundle are you using?

robertsLando avatar Nov 30 '23 06:11 robertsLando

What's the error you see? Is it on compilation time or runtime? What bundle are you using?

mqqt 5.3.1 Introduced like this import mqtt from 'mqtt' With uniapp, running to app-plus android I get the following error

image

If I introduce it like this const mqtt = require("mqtt")

image

uniapp official website https://uniapp.dcloud.net.cn/

surge-squirrel avatar Nov 30 '23 07:11 surge-squirrel

What's the error you see? Is it on compilation time or runtime? What bundle are you using?

uniapp only supports es in android environment, not webapi. i see a lot of window, Navigator and other webapi in the packaged file, it should be these that cause the error.

surge-squirrel avatar Nov 30 '23 08:11 surge-squirrel

language is not present in source code so sincerly I have no clue what that error means

robertsLando avatar Nov 30 '23 09:11 robertsLando

language is not present in source code so sincerly I have no clue what that error means

Inside the packaged code is Navigator.language

surge-squirrel avatar Nov 30 '23 10:11 surge-squirrel

language is not present in source code so sincerly I have no clue what that error means

image

surge-squirrel avatar Nov 30 '23 10:11 surge-squirrel

Feel free to submit a PR to fix your issue

robertsLando avatar Nov 30 '23 10:11 robertsLando

Feel free to submit a PR to fix your issue

It could be caused by using this plugin esbuild-plugin-polyfill-node when packing the package But I'm not familiar with esbuild, could you please pay attention to it?

surge-squirrel avatar Dec 04 '23 10:12 surge-squirrel

Try with v 5.3.6

robertsLando avatar Feb 26 '24 09:02 robertsLando