0

I try to use the react-pdf library to generate pdf.

But when I do this I have an error like this:

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: { "assert": require.resolve("assert/") }' - install 'assert' If you don't want to include a polyfill, you can use an empty module like this: resolve.fallback: { "assert": false } resolve 'assert' in 'C:\Users\SMAX\OneDrive\Projets Autres\exxotax_react\node_modules\browserify-zlib\lib'

Now, after installing some packages the React/Webpack is compiled from npm run start. But I have the following error:

Buffer is not defined And nothing appear on screen.

How can I fix it? I tried :

  • Install all libraries needed
  • Watch on internet some solution

The only solution I saw was something like:

Creating a webpack.config.js and add:

resolve: {
extensions: [ '.ts', '.js' ],
fallback: {
    "stream": require.resolve("stream-browserify"),
    "buffer": require.resolve("buffer")
} },

But how can I add these lines in the config file? Do I need a new config file/package.json ? If yes how can I do?

2 Answers 2

2

To extend create-react-app webpack config, you will need to use craco or rewired instead of react-scripts

Craco: https://github.com/gsoft-inc/craco

Rewired: https://github.com/timarney/react-app-rewired

Sign up to request clarification or add additional context in comments.

Comments

0

I finally updated all packages and use a workaorund because of a "conflict" with webpack.

2 Comments

Which workaround?
I dont' remember exactly but a package like starlett was bad after updating. I downgrade package like uvicorn etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.