Jest is encountering issues locating the package canvas in dependencies even though it exists. Running yarn run test
results in failure with the specific error below.
packages/first/src/layouts/EventsTable.spec.tsx
● Test suite failed to run
Cannot find module '../build/Release/canvas.node'
Require stack:
- /Users/abc/Documents/monorepo/node_modules/canvas/lib/bindings.js
- /Users/abc/Documents/monorepo/node_modules/canvas/lib/canvas.js
- /Users/abc/Documents/monorepo/node_modules/canvas/index.js
- /Users/abc/Documents/monorepo/node_modules/jsdom/lib/jsdom/utils.js
- /Users/abc/Documents/monorepo/node_modules/jsdom/lib/jsdom/living/events/MouseEvent-impl.js
- /Users/abc/Documents/monorepo/node_modules/jsdom/lib/jsdom/living/generated/MouseEvent.js
- /Users/abc/Documents/monorepo/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js
- /Users/abc/Documents/monorepo/node_modules/jsdom/lib/jsdom/living/aborting/AbortSignal-impl.js
- /Users/abc/Documents/monorepo/node_modules/jsdom/lib/jsdom/living/generated/AbortSignal.js
- /Users/abc/Documents/monorepo/node_modules/jsdom/lib/jsdom/living/generated/AddEventListenerOptions.js
......
The canvas package has been installed and is listed as a dependency.
yarn why canvas
└─ pdfjs-dist@npm:3.11.174
└─ canvas@npm:2.11.2 (via npm:^2.11.2)
Attempts were made to resolve the issue by removing all packages with rm -rf node_modules
and reinstalling, however the problem persists.
Node version - v18.16.1
yarn version - v3.2.3