使用node-rdkafka软件包运行Vue时出错

zi8p0yeb  于 2022-11-21  发布在  Apache
关注(0)|答案(1)|浏览(300)

我在我的应用程序中安装了node-rdkafka。npm安装node-rdkafka
在我的代码中。
第一个
运行时出错npm运行dev

ERROR in ./node_modules/node-rdkafka/lib/kafka-consumer-stream.js 14:15-41
Module not found: Error: Can't resolve 'stream' in '/root/Sites/NDE-Frontend/node_modules/node-rdkafka/lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
        - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "stream": false }

ERROR in ./node_modules/node-rdkafka/lib/producer-stream.js 14:15-41
Module not found: Error: Can't resolve 'stream' in '/root/Sites/NDE-Frontend/node_modules/node-rdkafka/lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
        - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "stream": false }

ERROR in ./node_modules/node-rdkafka/node_modules/bindings/bindings.js 5:9-22
Module not found: Error: Can't resolve 'fs' in '/root/Sites/NDE-Frontend/node_modules/node-rdkafka/node_modules/bindings'

ERROR in ./node_modules/node-rdkafka/node_modules/bindings/bindings.js 6:9-24
Module not found: Error: Can't resolve 'path' in '/root/Sites/NDE-Frontend/node_modules/node-rdkafka/node_modules/bindings'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
        - install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "path": false }

ERROR in ./node_modules/node-rdkafka/node_modules/file-uri-to-path/index.js 6:10-29
Module not found: Error: Can't resolve 'path' in '/root/Sites/NDE-Frontend/node_modules/node-rdkafka/node_modules/file-uri-to-path'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
        - install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "path": false }

webpack compiled with 5 errors
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @neubus/nde-frontend@ development: `mix`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @neubus/nde-frontend@ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-11-16T14_25_47_382Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @neubus/nde-frontend@ dev: `npm run development`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @neubus/nde-frontend@ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

有人遇到过同样的问题吗?

mwkjh3gx

mwkjh3gx1#

我只是把它添加到我的webpack.config.js来解决这个问题。

fallback: {
            "stream": false,
            "fs": false,
            "tls": false,
            "net": false,
            "path": false,
            "zlib": false,
            "http": false,
            "https": false,
            "stream": false,
            "crypto": false,
            "crypto-browserify": require.resolve('crypto-browserify'),
        }

相关问题