DEV Community

Discussion on: React & PDF Rendering

Collapse
 
souravojha profile image
sourav-ojha

Could not resolve dependency:
npm ERR! peer react-scripts@"^4.0.0" from @craco/craco@6.4.3

Collapse
 
przpiw profile image
Damian Piwowarczyk

You need to update your react-script package. As craco@6.4.3 needs at least react-script@4.0.0 to run.
create-react-app.dev/docs/updating...
Hope that helped.

Collapse
 
pedrinho_force profile image
Pedro Henrique Cardoso Lima

Hi @przpiw,

Thanks for the article.I have been trying to play around with React-PDF... and I keep receiving the following error:

Module not found: Error: Can't resolve 'stream' in '/Users/pedrolima/Desktop/React_Projects/app/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 }

I have looked the error online and I am not yet what I am doing wrong. I would appreciate so much your help.

My settings:
"@craco/craco": "^6.4.3",
"@react-pdf/renderer": "^2.1.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "5.0.0"

Thread Thread
 
pedrinho_force profile image
Pedro Henrique Cardoso Lima

Hi @przpiw ,

When I run your project this is what i get (img below). I don't think that's expected to happen. Right?

Thread Thread
 
rdani95 profile image
Rausz Dániel

Craco doesn't support CRA 5 yet, but there is an open issue about it
github.com/gsoft-inc/craco/issues/378

In the meantime, there is an alpha version (v7.0.0-alpha.0). I could install it with CRA5 app, withouth ejecting.

npm install @craco/craco@v7.0.0-alpha.0

react-pdf-renderer works fine with this version.

CC @souravojha