Automattic / Automattic/node-canvas

Node-canvas dependency packages are too large to build project on Netlify

Open
#1,954 11 comments 5 reactions 0 assignees View on GitHub
Binaries
Dominant language
JavaScript
Stars
10.7k
Forks
1.2k
Avg merge
4d 8h
Merged PRs (30d)
1

Description

## Steps to Reproduce
Follow the installation guide.
I am running on OS Big Sur 11.5.2: and I had trouble initially using, so I ran the OS command for compiling :

brew install pkg-config cairo pango libpng jpeg giflib librsvg.

I then import 'canvas' into a Nextjs Api Route to watermark images in a node environment before sending to the server (as I cannot load the non-watermarked images into the browser in any scenario.

This works completely fine on my local machine - BUT when I try to push my project to netflify - which pushes to AWS, it is trying to install the package in a different environment. I assume this is totally normal, however, the dependency package for node-canvas named librsvg-2.so.2 is very large. It causes my project size to go over the maximum limit.

I do not even need librsvg-2.so.2 (as in I do not need support for svg's). So I then prevent downloading this node dependency on build, which works to build the project and push it live. However, now when I call my api route the package crashes as its missing a dependency--Which I thought this was not a necessary dependency to node-canvas? Only an optional one?

Any thoughts on this? Has anyone run into a similar situation trying to use node-canvas while hosting on netlify?

Many thanks in advance!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.