Skip to content

Buffer is not defined #1294

Closed
Closed
@wsw70

Description

@wsw70

When importing MQTT.js to a VueJS/Quasar app, I get the following error:

app.js:216 Uncaught ReferenceError: Buffer is not defined
    at eval (constants.js?885d:46)
    at Object../node_modules/mqtt-packet/constants.js (vendor.js:1729)
    at __webpack_require__ (app.js:213)
    at fn (app.js:477)
    at eval (parser.js?7aac:4)
    at Object../node_modules/mqtt-packet/parser.js (vendor.js:1779)
    at __webpack_require__ (app.js:213)
    at fn (app.js:477)
    at eval (mqtt.js?e7bd:1)
    at Object../node_modules/mqtt-packet/mqtt.js (vendor.js:1749)
eval @ constants.js?885d:46
./node_modules/mqtt-packet/constants.js @ vendor.js:1729
__webpack_require__ @ app.js:213
fn @ app.js:477
eval @ parser.js?7aac:4
./node_modules/mqtt-packet/parser.js @ vendor.js:1779
__webpack_require__ @ app.js:213
fn @ app.js:477
eval @ mqtt.js?e7bd:1
./node_modules/mqtt-packet/mqtt.js @ vendor.js:1749
__webpack_require__ @ app.js:213
fn @ app.js:477
eval @ client.js?9905:8
./node_modules/mqtt/lib/client.js @ vendor.js:1800
__webpack_require__ @ app.js:213
fn @ app.js:477
eval @ index.js?4c91:3
./node_modules/mqtt/lib/connect/index.js @ vendor.js:1822
__webpack_require__ @ app.js:213
fn @ app.js:477
eval @ index.js??clonedRuleSet-3.use[0]!./node_modules/@quasar/app/lib/webpack/loader.vue.auto-import-quasar.js??ruleSet[0].use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[1]!./src/App.vue?vue&type=script&lang=ts:6
./node_modules/@quasar/app/lib/webpack/loader.js.transform-quasar-imports.js!./node_modules/ts-loader/index.js??clonedRuleSet-3.use[0]!./node_modules/@quasar/app/lib/webpack/loader.vue.auto-import-quasar.js??ruleSet[0].use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[1]!./src/App.vue?vue&type=script&lang=ts @ app.js:63
__webpack_require__ @ app.js:213
fn @ app.js:477
eval @ App.vue?vue&type=script&lang=ts:5
./src/App.vue?vue&type=script&lang=ts @ app.js:134
__webpack_require__ @ app.js:213
fn @ app.js:477
eval @ App.vue:6
./src/App.vue @ app.js:96
__webpack_require__ @ app.js:213
fn @ app.js:477
eval @ app.js:6
./.quasar/app.js @ app.js:19
__webpack_require__ @ app.js:213
fn @ app.js:477
eval @ client-entry.js:11
./.quasar/client-entry.js @ app.js:30
__webpack_require__ @ app.js:213
(anonymous) @ app.js:1387
__webpack_require__.O @ app.js:260
(anonymous) @ app.js:1388
(anonymous) @ app.js:1390

I tried (more or less randomly, after finding a similar issue) to

npm install Buffer

which chnaged the error to

Uncaught TypeError: Buffer.alloc is not a function
    at eval (constants.js?885d:128)
    at Array.map (<anonymous>)
    at eval (constants.js?885d:127)
    at Array.map (<anonymous>)
    at eval (constants.js?885d:126)
    at Array.map (<anonymous>)
    at genHeader (constants.js?885d:125)
    at eval (constants.js?885d:140)
    at Object../node_modules/mqtt-packet/constants.js (vendor.js:1707)
    at __webpack_require__ (app.js:213)

Please let me know if I can help with the debug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions