Babel.js 未捕获引用错误:未在varintEncode(util.js:33:1)处定义缓冲区-由于这样做,我的应用程序崩溃

isr3a4wc  于 2022-12-08  发布在  Babel
关注(0)|答案(1)|浏览(174)

我们的应用程序在控制台中显示此错误。如果有人知道此错误,请提供帮助。
错误-

Uncaught ReferenceError: Buffer is not defined
    at varintEncode (util.js:33:1)
    at ./node_modules/multicodec/src/varint-table.js (varint-table.js:11:1)
    at options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:62:1)
    at ./node_modules/multicodec/src/index.js (index.js:16:1)
    at options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:62:1)
    at ./node_modules/content-hash/src/index.js (index.js:19:1)[enter image description here][1]
l0oc07j2

l0oc07j21#

我通过以下步骤成功地解决了这个问题:
1.卸载Webpack 5:npm卸载webpack
1.删除包-lock.json
1.转到package.json并从“React-scripts”进行更改:“5.0.0”到“React脚本”:“4.0.3”、
1.安装Webpack 4:npm安装webpack@4.44.2

  1. npm安装
  2. npm运行开始
    我希望它能有所帮助,如果是的话,不要犹豫,投赞成票;)

相关问题