Skip to content

Canvas install failed on docker. #2545

Closed

Description

@fahad-6sensehq

In my NestJS app, I used canvas for exporting graphs from my system. Canvas work properly on my local machine (Windows). But when I try to dockerize it for AWS ECR, its failed. Facing with error form last week before that everything was fine. Is it node:22-apline issue or canvas issue?

How can I resolve this issue?

[deps 6/6] RUN pnpm install:
64.81 .../canvas@3.2.0/node_modules/canvas install: gyp ERR! stack Error: make failed with exit code: 2
64.81 .../canvas@3.2.0/node_modules/canvas install: gyp ERR! stack at ChildProcess. (/usr/local/lib/node_modules/pnpm/dist/node_modules/node-gyp/lib/build.js:216:23)
64.81 .../canvas@3.2.0/node_modules/canvas install: gyp ERR! System Linux 6.11.0-1018-azure
64.81 .../canvas@3.2.0/node_modules/canvas install: gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/pnpm/dist/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
64.81 .../canvas@3.2.0/node_modules/canvas install: gyp ERR! cwd /app/node_modules/.pnpm/canvas@3.2.0/node_modules/canvas
64.81 .../canvas@3.2.0/node_modules/canvas install: gyp ERR! node -v v22.21.1
64.81 .../canvas@3.2.0/node_modules/canvas install: gyp ERR! node-gyp -v v10.3.1
64.81 .../canvas@3.2.0/node_modules/canvas install: gyp ERR! not ok
64.81 .../canvas@3.2.0/node_modules/canvas install: Failed
64.83  ELIFECYCLE  Command failed with exit code 1.

GitHub Actions Error:

Image Image

My docker file:

FROM node:22-alpine AS deps
WORKDIR /app

RUN apk add --no-cache
python3
make
g++
pkgconfig
cairo-dev
pango-dev
jpeg-dev
giflib-dev
fontconfig
ttf-dejavu

RUN npm install -g pnpm@9

COPY package.json ./

RUN pnpm install

Activity

  1. trolloks commented on Dec 8, 2025

    @trolloks

    I have the exact docker setup - node:22-alpine, pnpm and also running Windows locally. I am also experiencing the exact same issue.

    Update:
    I got it to build by downgrading to the following version.

    {
       ...
      "canvas": "3.0.1",
       ...
    }
    
  2. fahad-6sensehq commented on Dec 8, 2025

    @fahad-6sensehq
    Author

    @trolloks yes, canvas@3.0.1 works. But I'm using another package called "chartjs-node-canvas" which is using canvas@3.2.0 under the hood.

    dependencies:
    canvas 3.0.1
    chartjs-node-canvas 5.0.0
    └── canvas 3.2.0

    That's why I'm still facing the issue. Looks like it's canvas@3.2.0 version's issue.

  3. deryabilisim commented on Dec 8, 2025

    @deryabilisim

    @trolloks yes, canvas@3.0.1 works. But I'm using another package called "chartjs-node-canvas" which is using canvas@3.2.0 under the hood.

    dependencies: canvas 3.0.1 chartjs-node-canvas 5.0.0 └── canvas 3.2.0

    That's why I'm still facing the issue. Looks like it's canvas@3.2.0 version's issue.

    I’m experiencing the same issue. The Dockerfile was building 3–4 days ago with no problems, and there haven’t been any code changes, but now it doesn’t build. It doesn’t make sense to me.

    Image
  4. fralways commented on Dec 9, 2025

    @fralways

    add CXXFLAGS as a temp workaround to make it work:

    example:

    old: RUN yarn install --immutable
    new: RUN CXXFLAGS="-include cstdint" yarn install --immutable

    fix should come from canvas to handle new GCC

  5. jmlavoier commented on Dec 9, 2025

    @jmlavoier

    My canvas version is @2.11.2 and I'm facing the same issue. It was resolved by setting the CXXFLAGS variable, as @fralways suggested. I will subscribe to this issue to follow up on the definitive solution.

  6. fahad-6sensehq commented on Dec 10, 2025

    @fahad-6sensehq
    Author

    @fralways CXXFLAGS variable worked for canvas@3.2.0

    Hope canvas officially resolve this issue soon.

  7. Koyamie commented on Dec 12, 2025

    @Koyamie

    Same issue here, works fine with bullseye image but fails with alpine.

  8. added 2 commits that reference this issue on Dec 16, 2025
    2b5cdc9
    0953711
  9. skooch commented on Dec 16, 2025

    @skooch
    Contributor

    This is due to C++ standard library changes in GCC 15. I have a pull request with a fix in #2546

  10. chearon commented on Jan 10, 2026

    @chearon
    Collaborator

    Fixed by #2546 which you can get by using version 3.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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