wojtekmaj / react-pdf

Display PDFs in your React app as easily as if they were images.
https://projects.wojtekmaj.pl/react-pdf
MIT License
9.11k stars 867 forks source link

Cannot find module '../build/Release/canvas.node' error when running jest test #1702

Closed courtneypattison closed 6 months ago

courtneypattison commented 6 months ago

Before you start - checklist

Description

My Jest tests fail to run with the error message Cannot find module '../build/Release/canvas.node' when I have react-pdf installed.

Steps to reproduce

pnpm test

Expected behavior

Tests should run

Actual behavior

Cannot find module '../build/Release/canvas.node'

Additional information

$ pnpm rebuild
node_modules/.pnpm/canvas@2.11.2/node_modules/canvas: Running install script, failed in 1.1s (skipped as optional)

$ pnpm why canvas
dependencies:
react-pdf 7.7.0
└─┬ pdfjs-dist 3.11.174
  └── canvas 2.11.2

Environment

wojtekmaj commented 6 months ago

See also https://github.com/Automattic/node-canvas/issues/2135

courtneypattison commented 6 months ago

Thank you @wojtekmaj! It's a pnpm issue.