Skip to content

MQTT.js import error: This browser lacks typed array (Uint8Array) support which is required by buffer v5.x. Use buffer v4.x if you require old browser support. #10105

Answered by josephrocca
vmasdani asked this question in Q&A
Discussion options

You must be logged in to vote

I'm guessing this is because MQTT.js contains a browserified version of Node.js's Buffer, and that package tries to change prototypes using __proto__. This doesn't work because, unlike browsers, Deno doesn't allow __proto__ to be overwritten (relevant issue). One way to fix this (as mentioned here) is to replace all instances of obj.__proto__ = newPrototype with Object.setPrototypeOf(obj, newPrototype).

But actually, it looks like the latest version of browserify's Buffer uses setPrototypeOf instead of __proto__, so you may just be able to ask the maintainer of https://github.com/mqttjs/MQTT.js to re-browserify the package and publish a new version.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by kitsonk
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #10102 on April 10, 2021 03:41.