`canvas` dependency missing for node
CPatchane opened this issue · comments
Greetings 👋
I'd like to bring attention to an issue with the konva
package. The Node.js version of konva
utilizes the canvas
dependency, but it is not listed in the konva
package.json. This omission leads to problems when installing konva
using a package manager like pnpm, which only exposes necessary dependencies (compared to yarn v1 or npm).
To reproduce this issue, install konva
via pnpm and attempt to run Jest tests on files that use konva
. You'll encounter the following error:
Cannot find module 'canvas' from 'node_modules/.pnpm/konva@9.3.6/node_modules/konva/lib/index-node.js'
This issue likely didn't exist when the Node.js version was separate, as in konva-node
.
Proposed Solution 1: Include canvas
as a dependency in konva
's package.json. This should resolve the issue.
Proposed Solution 2: Mention in the documentation to install canvas
when using konva
in a node environment.
It is mentioned in the docs: https://github.com/konvajs/konva?tab=readme-ov-file#4-nodejs-env
Note: I don't add canvas
into package.json
because the major part of use cases is frontend only. So I don't want to pollute node_modules
that is already too big everywhere.
Oops sorry I missed that info in the documentation, thanks for the link and that quick reply 🙌