Error: Cannot find module 'graphicsmagick' when running n8n worker (v1.103.2)

Hi everyone,

I’m encountering an issue when starting the n8n worker in version 1.103.2. The worker fails to start with the following error:

2025-07-28T15:05:47.171Z | error | [Task Runner]: Task runner failed to start {
  error: Error: Cannot find module 'graphicsmagick'
  Require stack:
  - /usr/local/lib/node_modules/n8n/node_modules/.pnpm/@n8n+task-runner@.../js-task-runner.js
  ...
  code: 'MODULE_NOT_FOUND'
}

It looks like the @n8n/task-runner module is attempting to require graphicsmagick, but it fails with MODULE_NOT_FOUND. I’m not directly using GraphicsMagick in any of my workflows.

I’ve already installed the graphicsmagick binary in my custom Docker image via apt-get install graphicsmagick, and even added gm via npm (npm install -g gm), but the error persists.

Here is a snippet of the Dockerfile I’m using to build my custom image for the worker:

Click to expand Dockerfile
ARG NODE_VERSION=22
ARG N8N_VERSION=snapshot
ARG LAUNCHER_VERSION=1.1.3
ARG TARGETPLATFORM

FROM n8n-base:1.103.2_node-${NODE_VERSION}_slim-bullseye AS system-deps

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        graphicsmagick \
        ... # other system dependencies \
        && apt-get clean && rm -rf /var/lib/apt/lists/*

# ... additional stages ...

FROM system-deps AS runtime

RUN npm install -g gm [email protected] puppeteer ffmpeg git

Questions:

  1. Is graphicsmagick expected to be installed as an npm module (like gm) or just as a system binary?
  2. Why would the @n8n/task-runner module throw a MODULE_NOT_FOUND if gm is globally installed?
  3. Is there a required environment variable or configuration I might be missing to make it work?
  4. Could this be a bug or something related to task-runner packaging in version 1.103.2?

Any guidance or recommendations would be greatly appreciated. Thank you so much!

Your n8n worker is failing because the @n8n/task-runner module specifically cannot find graphicsmagick as a Node.js module, even though you’ve installed the binary and gm (the Node.js wrapper).
The core issue is that graphicsmagick (the Node.js module itself, not just the CLI tool or the gm wrapper) is a direct dependency of @n8n/task-runner.
Solution:
You need to ensure the graphicsmagick Node.js package is installed alongside n8n’s dependencies. Since apt-get install graphicsmagick installs the system binary and npm install -g gm installs the wrapper, neither directly fulfills the @n8n/task-runner’s specific Node.js graphicsmagick module requirement.
Add npm install graphicsmagick to your Dockerfile, specifically within the n8n installation context, to ensure the module is available to the task runner.

I tried installing graphicsmagick via npm using this command in the Dockerfile:

RUN npm install -g graphicsmagick

However, the build fails with the following error:

#18 [runtime 8/9] RUN npm install -g graphicsmagick
#18 2.061 npm error code 127
#18 2.061 npm error path /usr/local/lib/node_modules/graphicsmagick
#18 2.061 npm error command failed
#18 2.061 npm error command sh -c node-waf clean || (exit 0); node-waf configure build
#18 2.061 npm error sh: 1: node-waf: not found
#18 2.061 npm error sh: 1: node-waf: not found
#18 2.061 npm error A complete log of this run can be found in: /root/.npm/_logs/2025-07-29T08_00_30_071Z-debug-0.log
#18 ERROR: process "/bin/sh -c npm install -g graphicsmagick" did not complete successfully: exit code: 127

After some digging, I realized that node-waf is deprecated and no longer supported in recent Node.js versions — including Node.js v22, which I’m currently using.

  1. Is there a way to use the graphicsmagick npm module (or an alternative) that’s compatible with Node.js v22?
  2. Since n8n v1.103.2 uses Node.js v22, how are we supposed to deal with packages that rely on outdated build systems like node-waf?
  3. Should I avoid using the npm package altogether and just rely on the system-level graphicsmagick binary?
  4. Is graphicsmagick actually required by n8n itself or just by specific nodes?

Let’s break this down simply:

  • Node.js v22 & graphicsmagick npm module: The direct graphicsmagick npm module is not directly compatible with Node.js v22. It relies on an outdated build system (node-waf) that’s no longer supported by newer Node.js versions.

  • Dealing with outdated build systems: You should avoid npm packages that rely on node-waf or similar outdated build systems with Node.js v22. They won’t compile correctly.

  • Rely on system-level binary? Yes, largely. The best approach for Node.js v22 with graphicsmagick is to:

    • Install the graphicsmagick system-level binary (e.g., apt-get install graphicsmagick).

    • Use the gm npm package (which is a wrapper) to interact with the installed system binary from your Node.js application.

  • Is graphicsmagick required by n8n or specific nodes? The error message indicates that @n8n/task-runner (a core n8n module) is attempting to require the graphicsmagick npm module. This suggests it’s a core dependency for parts of n8n’s functionality or its task execution environment, not just specific nodes you might be using. It’s likely used internally for image processing, thumbnails, or other utility functions that some nodes might indirectly trigger.

In essence: Ditch the graphicsmagick npm module. Install the system binary and use the gm npm package to bridge the gap for n8n.

1 Like

Thanks a lot, bro! I managed to fix the error using this Dockerfile, leaving it here in case anyone runs into the same issue

N8N

ARG NODE_VERSION=22
ARG N8N_VERSION=snapshot
ARG LAUNCHER_VERSION=1.1.3
ARG TARGETPLATFORM

# ==============================================================================
# STAGE 1: System Dependencies & Base Setup
# ==============================================================================
FROM sretools/n8n-base:1.103.2_node-${NODE_VERSION}_slim-bullseye AS system-deps

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        ca-certificates \
        curl \
        wget \
        git \
        openssh-client \
        fontconfig \
        ttf-mscorefonts-installer \
        tini \
        jq \
        tzdata \
        sqlite3 \
        python3 \
        build-essential \
        libc6-dev \
        libpixman-1-dev \
        libglib2.0-0 \
        libnss3 \
        libx11-6 \
        libxext6 \
        libxrender1 \
        libxrandr2 \
        libxcb1 \
        libxcomposite1 \
        libxdamage1 \
        libxfixes3 \
        libxi6 \
        libxtst6 \
        libatk1.0-0 \
        libatk-bridge2.0-0 \
        libgtk-3-0 \
        libjpeg-dev \
        libpng-dev \
        libtiff-dev \
        xz-utils \
        && apt-get clean && rm -rf /var/lib/apt/lists/*

WORKDIR /opt

RUN wget https://sourceforge.net/projects/graphicsmagick/files/graphicsmagick/1.3.45/GraphicsMagick-1.3.45.tar.xz && \
    tar -xf GraphicsMagick-1.3.45.tar.xz && \
    cd GraphicsMagick-1.3.45 && \
    ./configure && \
    make && \
    make install && \
    cd .. && \
    rm -rf GraphicsMagick-1.3.45 GraphicsMagick-1.3.45.tar.xz

RUN gm version

# ==============================================================================
# STAGE 2: Application Artifact Processor
# ==============================================================================
FROM debian:bullseye-slim AS app-artifact-processor

COPY ./compiled /app/

# ==============================================================================
# STAGE 3: Task Runner Launcher
# ==============================================================================
FROM debian:bullseye-slim AS launcher-downloader

ARG TARGETPLATFORM
ARG LAUNCHER_VERSION

RUN apt-get update && apt-get install -y wget ca-certificates && \
    set -e; \
    case "$TARGETPLATFORM" in \
        "linux/amd64") ARCH_NAME="amd64" ;; \
        "linux/arm64") ARCH_NAME="arm64" ;; \
        *) echo "Unsupported platform: $TARGETPLATFORM" && exit 1 ;; \
    esac; \
    mkdir /launcher-temp && cd /launcher-temp; \
    wget -q "https://github.com/n8n-io/task-runner-launcher/releases/download/${LAUNCHER_VERSION}/task-runner-launcher-${LAUNCHER_VERSION}-linux-${ARCH_NAME}.tar.gz"; \
    wget -q "https://github.com/n8n-io/task-runner-launcher/releases/download/${LAUNCHER_VERSION}/task-runner-launcher-${LAUNCHER_VERSION}-linux-${ARCH_NAME}.tar.gz.sha256"; \
    echo "$(cat task-runner-launcher-${LAUNCHER_VERSION}-linux-${ARCH_NAME}.tar.gz.sha256) task-runner-launcher-${LAUNCHER_VERSION}-linux-${ARCH_NAME}.tar.gz" > checksum.sha256; \
    sha256sum -c checksum.sha256; \
    mkdir -p /launcher-bin; \
    tar xzf task-runner-launcher-${LAUNCHER_VERSION}-linux-${ARCH_NAME}.tar.gz -C /launcher-bin; \
    cd / && rm -rf /launcher-temp

# ==============================================================================
# STAGE 4: Final Runtime Image
# ==============================================================================
FROM system-deps AS runtime

ARG N8N_VERSION
ARG N8N_RELEASE_TYPE=dev
ENV NODE_ENV=production
ENV N8N_RELEASE_TYPE=${N8N_RELEASE_TYPE}
ENV NODE_ICU_DATA=/usr/local/lib/node_modules/full-icu
ENV SHELL=/bin/bash

WORKDIR /n8n/main

COPY --from=app-artifact-processor /app /usr/local/lib/node_modules/n8n
COPY --from=launcher-downloader /launcher-bin/* /usr/local/bin/
COPY docker/images/n8n/docker-entrypoint.sh /
COPY docker/images/n8n/n8n-task-runners.json /etc/n8n-task-runners.json

RUN cd /usr/local/lib/node_modules/n8n && \
    npm rebuild sqlite3 && \
    ln -s /usr/local/lib/node_modules/n8n/bin/n8n /usr/local/bin/n8n && \
    mkdir -p /n8n/main/.n8n && \
    chown -R node:node /n8n/main

# Install npm to patch brace-expansion vulnerability
RUN npm install -g [email protected] puppeteer ffmpeg git gm

# Install @napi-rs/canvas inside pdfjs-dist
RUN cd /usr/local/lib/node_modules/n8n/node_modules/pdfjs-dist && npm install @napi-rs/canvas

EXPOSE 5678/tcp
USER node
ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]

LABEL org.opencontainers.image.title="n8n" \
      org.opencontainers.image.description="Workflow Automation Tool" \
      org.opencontainers.image.source="https://github.com/n8n-io/n8n" \
      org.opencontainers.image.url="https://n8n.io" \
      org.opencontainers.image.version=${N8N_VERSION}

N8N Base

ARG NODE_VERSION=22
ARG N8N_VERSION=snapshot
ARG LAUNCHER_VERSION=1.1.3
ARG TARGETPLATFORM

# ==============================================================================
# STAGE 1: System Dependencies & Base Setup
# ==============================================================================
FROM sretools/n8n-base:1.103.2_node-${NODE_VERSION}_slim-bullseye AS system-deps

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        ca-certificates \
        curl \
        wget \
        git \
        openssh-client \
        fontconfig \
        ttf-mscorefonts-installer \
        tini \
        jq \
        tzdata \
        sqlite3 \
        python3 \
        build-essential \
        libc6-dev \
        libpixman-1-dev \
        libglib2.0-0 \
        libnss3 \
        libx11-6 \
        libxext6 \
        libxrender1 \
        libxrandr2 \
        libxcb1 \
        libxcomposite1 \
        libxdamage1 \
        libxfixes3 \
        libxi6 \
        libxtst6 \
        libatk1.0-0 \
        libatk-bridge2.0-0 \
        libgtk-3-0 \
        libjpeg-dev \
        libpng-dev \
        libtiff-dev \
        xz-utils \
        && apt-get clean && rm -rf /var/lib/apt/lists/*

WORKDIR /opt

RUN wget https://sourceforge.net/projects/graphicsmagick/files/graphicsmagick/1.3.45/GraphicsMagick-1.3.45.tar.xz && \
    tar -xf GraphicsMagick-1.3.45.tar.xz && \
    cd GraphicsMagick-1.3.45 && \
    ./configure && \
    make && \
    make install && \
    cd .. && \
    rm -rf GraphicsMagick-1.3.45 GraphicsMagick-1.3.45.tar.xz

RUN gm version

# ==============================================================================
# STAGE 2: Application Artifact Processor
# ==============================================================================
FROM debian:bullseye-slim AS app-artifact-processor

COPY ./compiled /app/

# ==============================================================================
# STAGE 3: Task Runner Launcher
# ==============================================================================
FROM debian:bullseye-slim AS launcher-downloader

ARG TARGETPLATFORM
ARG LAUNCHER_VERSION

RUN apt-get update && apt-get install -y wget ca-certificates && \
    set -e; \
    case "$TARGETPLATFORM" in \
        "linux/amd64") ARCH_NAME="amd64" ;; \
        "linux/arm64") ARCH_NAME="arm64" ;; \
        *) echo "Unsupported platform: $TARGETPLATFORM" && exit 1 ;; \
    esac; \
    mkdir /launcher-temp && cd /launcher-temp; \
    wget -q "https://github.com/n8n-io/task-runner-launcher/releases/download/${LAUNCHER_VERSION}/task-runner-launcher-${LAUNCHER_VERSION}-linux-${ARCH_NAME}.tar.gz"; \
    wget -q "https://github.com/n8n-io/task-runner-launcher/releases/download/${LAUNCHER_VERSION}/task-runner-launcher-${LAUNCHER_VERSION}-linux-${ARCH_NAME}.tar.gz.sha256"; \
    echo "$(cat task-runner-launcher-${LAUNCHER_VERSION}-linux-${ARCH_NAME}.tar.gz.sha256) task-runner-launcher-${LAUNCHER_VERSION}-linux-${ARCH_NAME}.tar.gz" > checksum.sha256; \
    sha256sum -c checksum.sha256; \
    mkdir -p /launcher-bin; \
    tar xzf task-runner-launcher-${LAUNCHER_VERSION}-linux-${ARCH_NAME}.tar.gz -C /launcher-bin; \
    cd / && rm -rf /launcher-temp

# ==============================================================================
# STAGE 4: Final Runtime Image
# ==============================================================================
FROM system-deps AS runtime

ARG N8N_VERSION
ARG N8N_RELEASE_TYPE=dev
ENV NODE_ENV=production
ENV N8N_RELEASE_TYPE=${N8N_RELEASE_TYPE}
ENV NODE_ICU_DATA=/usr/local/lib/node_modules/full-icu
ENV SHELL=/bin/bash

WORKDIR /n8n/main

COPY --from=app-artifact-processor /app /usr/local/lib/node_modules/n8n
COPY --from=launcher-downloader /launcher-bin/* /usr/local/bin/
COPY docker/images/n8n/docker-entrypoint.sh /
COPY docker/images/n8n/n8n-task-runners.json /etc/n8n-task-runners.json

RUN cd /usr/local/lib/node_modules/n8n && \
    npm rebuild sqlite3 && \
    ln -s /usr/local/lib/node_modules/n8n/bin/n8n /usr/local/bin/n8n && \
    mkdir -p /n8n/main/.n8n && \
    chown -R node:node /n8n/main

# Install npm to patch brace-expansion vulnerability
RUN npm install -g [email protected] puppeteer ffmpeg git gm

# Install @napi-rs/canvas inside pdfjs-dist
RUN cd /usr/local/lib/node_modules/n8n/node_modules/pdfjs-dist && npm install @napi-rs/canvas

EXPOSE 5678/tcp
USER node
ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]

LABEL org.opencontainers.image.title="n8n" \
      org.opencontainers.image.description="Workflow Automation Tool" \
      org.opencontainers.image.source="https://github.com/n8n-io/n8n" \
      org.opencontainers.image.url="https://n8n.io" \
      org.opencontainers.image.version=${N8N_VERSION}
(base) root@gpu-p40-10-12-1-38-bt:/opt/n8n-1.130/n8n-1.103.2-builder# cat docker/images/n8n-base/Dockerfile
ARG NODE_VERSION=22

# ==============================================================================
# STAGE 1: Builder for Base Dependencies
# ==============================================================================
FROM node:${NODE_VERSION}-bullseye-slim AS builder

# Install fonts and essential build dependencies
RUN echo "deb http://deb.debian.org/debian bullseye main contrib" > /etc/apt/sources.list && \
    echo "deb http://security.debian.org/debian-security bullseye-security main contrib" >> /etc/apt/sources.list && \
    apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
        fontconfig \
        ttf-mscorefonts-installer \
        ca-certificates \
        wget \
        curl \
        git \
        openssh-client \
        openssl \
        graphicsmagick \
        tini \
        tzdata \
        jq \
        build-essential \
        libc6 && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

# Install ICU data and latest npm
RUN npm install -g [email protected] [email protected]

# Clean up
RUN rm -rf /tmp/* /root/.npm /root/.cache/node

# ==============================================================================
# STAGE 2: Final Base Runtime Image
# ==============================================================================
FROM node:${NODE_VERSION}-bullseye-slim

COPY --from=builder / /

WORKDIR /n8n/main
ENV NODE_ICU_DATA=/usr/local/lib/node_modules/full-icu
EXPOSE 5678/tcp
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.