Skip to content

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

Open
@scott-schibli

Description

@scott-schibli

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions