reactjs 为什么在React应用的App.js中导入mqtt模块时会出现此错误?

uplii1fm  于 2023-05-28  发布在  React
关注(0)|答案(1)|浏览(372)

我在以下位置得到此错误:从'mqtt'导入mqtt

ERROR
Buffer is not defined
ReferenceError: Buffer is not defined
    at ./node_modules/mqtt-packet/constants.js (http://localhost:3000/static/js/bundle.js:39648:34)
    at options.factory (http://localhost:3000/static/js/bundle.js:103411:31)
    at __webpack_require__ (http://localhost:3000/static/js/bundle.js:102835:33)
    at fn (http://localhost:3000/static/js/bundle.js:103068:21)
    at ./node_modules/mqtt-packet/parser.js (http://localhost:3000/static/js/bundle.js:39937:19)
    at options.factory (http://localhost:3000/static/js/bundle.js:103411:31)
    at __webpack_require__ (http://localhost:3000/static/js/bundle.js:102835:33)
    at fn (http://localhost:3000/static/js/bundle.js:103068:21)
    at ./node_modules/mqtt-packet/mqtt.js (http://localhost:3000/static/js/bundle.js:39844:18)
    at options.factory (http://localhost:3000/static/js/bundle.js:103411:31)

相关问题