'REACT-PDF library - webpack < 5 used to include polyfills for node.js core modules by default
Please, I am a student and I wanted to level up my skills by using different libraries and I have been trying to use react-pdf. I have followed this tutorial - it should be a quite "simple" project". (https://blog.logrocket.com/generating-pdfs-react/)
But when I run NPM START I get the following errors:
Module not found: Error: Can't resolve 'stream' in '/Users/pedrolima/Desktop/React_Projects/test_pdf_3/node_modules/@react-pdf/pdfkit/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/@react-pdf/pdfkit/lib/pdfkit.browser.es.js 4:0-24
Module not found: Error: Can't resolve 'zlib' in '/Users/pedrolima/Desktop/React_Projects/test_pdf_3/node_modules/@react-pdf/pdfkit/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: { "zlib": require.resolve("browserify-zlib") }' - install 'browserify-zlib' If you don't want to include a polyfill, you can use an empty module like this: resolve.fallback: { "zlib": false } [...]
I have looked for multiple solutions: like the one at the this post: How to Polyfill node core modules in webpack 5
as well as creating an config-overrides.js file.
I was still unable to run. I would appreciate if someone could help me. Many thanks!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|