我在我的应用程序中安装了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:
有人遇到过同样的问题吗?
1条答案
按热度按时间mwkjh3gx1#
我只是把它添加到我的
webpack.config.js
来解决这个问题。