未定义由stream browserify触发的webpack 5+进程

3z6pesqy  于 2021-09-23  发布在  Java
关注(0)|答案(0)|浏览(242)

我必须破译一个密码 CBOR 使用 cbor 节点模块。
当我启动命令时:

const decodedData = base45.decode(greenpassBody);
const output = pako.inflate(decodedData);
const results = cbor.decodeAllSync(output); // this line

正在触发此错误:

_stream_readable.js:529 Uncaught ReferenceError: process is not defined
    at emitReadable (_stream_readable.js:529)
    at addChunk (_stream_readable.js:303)
    at readableAddChunk (_stream_readable.js:280)
    at NoFilter.Readable.push (_stream_readable.js:241)
    at NoFilter.Transform.push (_stream_transform.js:139)
    at NoFilter._transform (index.js:220)
    at NoFilter.Transform._read (_stream_transform.js:177)
    at NoFilter.Transform._write (_stream_transform.js:164)
    at doWrite (_stream_writable.js:409)
    at writeOrBuffer (_stream_writable.js:398)

stram-browserify polyfill,在我的web应用程序中使用所有这些软件包所必需的。
当我在网上阅读时,我试图安装 process 模块在我的 package.json ,然后在我的 webpack 配置文件我尝试了几种方法:

fallback: {
  stream: require.resolve('stream-browserify'),
  util: require.resolve('util/'),
  zlib: require.resolve('browserify-zlib'),
  assert: require.resolve('assert/'),
  crypto: require.resolve('crypto-browserify'),
  fs: require.resolve('browserify-fs'),
  path: require.resolve('path-browserify'),
  process: require.resolve('process/browser'),  // <- this
}
alias: {
    'jquery-ui': path.resolve(__dirname, "./node_modules/jquery-ui"),
    'owl.carousel': path.resolve(__dirname, "./node_modules/owl.carousel"),
    modernizr$: path.resolve(__dirname, "./modernizrrc.js"),
    WOW: 'wowjs',
    process: "process/browser", // 1st try
    process: path.resolve(__dirname, "./node_modules/process/browser.js"), // 2nd try
},
plugins: [
      // ...
      new webpack.DefinePlugin({
         process: "process/browser"
        "process.env": {
          ASSET_PATH: JSON.stringify(ASSET_PATH),
          NODE_ENV: JSON.stringify("development"),
          ENV: JSON.stringify("development"),
        },
      }),

DefinePlugin “试试看,错误变了,”它说 browser is not defined .
任何人都知道如何正确填充此模块,或者是否有其他方法使用 CBOR 模块?
非常感谢

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题