From 27a794e7eb6bd2c8a7eedae4cc2932b6bd7266d1 Mon Sep 17 00:00:00 2001 From: Yury Kossakovsky Date: Tue, 9 Dec 2025 21:19:11 -0700 Subject: [PATCH] fix: install npm packages in task runner for code node support n8n v2.0 executes code nodes in a separate task runner container. the runner image (n8nio/runners) doesn't include npm packages like cheerio, axios, moment, lodash - causing "module is disallowed" errors. - add Dockerfile.runner with npm packages for code nodes - rename Dockerfile to Dockerfile.n8n for clarity - update docker-compose.yml to use custom runner build --- docker-compose.yml | 8 +++++++- n8n/{Dockerfile => Dockerfile.n8n} | 0 n8n/Dockerfile.runner | 10 ++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) rename n8n/{Dockerfile => Dockerfile.n8n} (100%) create mode 100644 n8n/Dockerfile.runner diff --git a/docker-compose.yml b/docker-compose.yml index 9a9799e..7e538d0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -37,6 +37,7 @@ volumes: x-n8n: &service-n8n build: context: ./n8n + dockerfile: Dockerfile.n8n pull: true args: N8N_VERSION: ${N8N_VERSION:-stable} @@ -111,7 +112,12 @@ x-init-ollama: &init-ollama # Worker-runner anchor for sidecar pattern (runner connects to worker via localhost) x-n8n-worker-runner: &service-n8n-worker-runner - image: n8nio/runners:${N8N_VERSION:-stable} + build: + context: ./n8n + dockerfile: Dockerfile.runner + pull: true + args: + N8N_VERSION: ${N8N_VERSION:-stable} environment: N8N_RUNNERS_AUTH_TOKEN: ${N8N_RUNNERS_AUTH_TOKEN} N8N_RUNNERS_AUTO_SHUTDOWN_TIMEOUT: 15 diff --git a/n8n/Dockerfile b/n8n/Dockerfile.n8n similarity index 100% rename from n8n/Dockerfile rename to n8n/Dockerfile.n8n diff --git a/n8n/Dockerfile.runner b/n8n/Dockerfile.runner new file mode 100644 index 0000000..bd2248a --- /dev/null +++ b/n8n/Dockerfile.runner @@ -0,0 +1,10 @@ +ARG N8N_VERSION=stable +FROM n8nio/runners:${N8N_VERSION} + +USER root + +# Install npm packages that can be used in Code nodes +# These must match NODE_FUNCTION_ALLOW_EXTERNAL in docker-compose.yml +RUN npm install -g cheerio axios moment lodash + +USER node