react-pdf icon indicating copy to clipboard operation
react-pdf copied to clipboard

Module not found: Can't resolve 'yoga-layout' with React 16.14.0 and Node 21

Open koranra opened this issue 4 months ago • 4 comments

Describe the bug Trying to import the library and generate a PDF and am running into issues - Module not found: Can't resolve 'yoga-layout' with React 16.14.0 and Node 21

To Reproduce attached sample code with a simple example. I followed all the things mentioned in this thread - https://github.com/diegomura/react-pdf/issues/2499. It works when I use renderer v3.1.14 and layout v3.6.3*, But it generates a empty pdf. So its breaking with that approach as well.

sample-app.zip

any help would be highly appreciated.

koranra avatar Feb 17 '24 15:02 koranra

The same problem with React 18.2 and Node v20.10

andrey-prokhorov avatar Feb 19 '24 09:02 andrey-prokhorov

@andrey-prokhorov it works for me if I upgrade to react 18 with node 21. But my app is on React 16.14 and thats where its causing the issue.

koranra avatar Feb 20 '24 00:02 koranra

I encounter the issue client side, packaging my app with Expo/Metro Bundler with the following error:

Unable to resolve "yoga-layout" from "node_modules/@react-pdf/layout/lib/index.cjs"

Node v21.6.2 React 18.2.0

jgo80 avatar Feb 22 '24 08:02 jgo80

@jgo80 @koranra @andrey-prokhorov @koranra

Add this in your package.json

"resolutions": { "@react-pdf/layout": "3.6.4", "@react-pdf/textkit": "4.3.0", "@react-pdf/image": "2.2.2", "@react-pdf/pdfkit": "3.1.2" }

PelosiTech avatar Feb 23 '24 23:02 PelosiTech

I fixed by adding to my package.json:

	"overrides": {
		"@react-pdf/layout": "3.6.4",
		"@react-pdf/textkit": "4.3.0",
		"@react-pdf/image": "2.2.2",
		"@react-pdf/pdfkit": "3.1.2"
	},

ytreister avatar Feb 28 '24 16:02 ytreister

Duplicate of #2499?

wojtekmaj avatar Mar 27 '24 07:03 wojtekmaj