Skip to content

Build Error: Incompatibility of canvas@2.11.2 with Node.js v22.11.0 #2448

Closed
@bahram-della-ai

Description

@bahram-della-ai

Description:

Hi there,

I'm experiencing build failures when trying to install canvas@2.11.2 using Node.js v22.11.0. It appears there might be compatibility issues between this version of Node.js and the canvas module.

Environment:

  • Node.js Version: v22.11.0
  • Canvas Version: 2.11.2
  • Platform: Linux (Docker base image node:lts-slim as of October 2024)
  • Dependency Manager: npm

Steps to Reproduce:

  1. Dockerfile Setup:

    FROM node:lts-slim AS build
    RUN apt-get update && apt-get install -y --no-install-recommends \
        make \
        g++ \
        dumb-init \
        build-essential \
        libcairo2-dev \
        libpango1.0-dev \
        libjpeg-dev \
        libgif-dev \
        librsvg2-dev \
        python3 \
        && rm -rf /var/lib/apt/lists/*
    
    WORKDIR /usr
    COPY package*.json tsconfig.json ./
    RUN npm ci
  2. Install Dependencies:

    • Run npm ci to install all dependencies, including canvas@2.11.2.
  3. Observe the Build Failure:

    • The installation fails during the build process of canvas.

Error Log Highlights:

npm ERR! code 1
npm ERR! path /usr/node_modules/canvas
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build --update-binary
npm ERR! make: Entering directory '/usr/node_modules/canvas/build'
npm ERR!   SOLINK_MODULE(target) Release/obj.target/canvas-postbuild.node
npm ERR!   COPY Release/canvas-postbuild.node
npm ERR!   CXX(target) Release/obj.target/canvas/src/backend/Backend.o
npm ERR! In file included from ../src/backend/Backend.h:6,
npm ERR!                  from ../src/backend/Backend.cc:1:
npm ERR! ../../nan/nan.h: In function 'void Nan::SetAccessor(...)':
npm ERR! ../../nan/nan.h:2546:19: error: no matching function for call to 'v8::ObjectTemplate::SetAccessor(...)'
npm ERR! ...
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! node -v v22.11.0

Additional Information:

  • Downgrading to Node.js v20.x resolves the issue; canvas installs without errors.

Questions:

  1. Compatibility Confirmation:

    • Is canvas@2.11.2 compatible with Node.js v22.11?
    • If not, are there plans to support Node.js v22.x in an upcoming release?
  2. Workarounds:

    • Are there any recommended steps or patches to make canvas work with Node.js v22.x?
  3. Dependency Updates:

    • Should we expect updates to dependencies like nan to address this compatibility issue?

Thank You:

Thank you for your time and assistance. Any guidance or updates on this matter would be greatly appreciated.

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