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
This commit is contained in:
Yury Kossakovsky
2025-12-09 21:19:11 -07:00
parent 5dc994eec6
commit 27a794e7eb
3 changed files with 17 additions and 1 deletions

View File

@@ -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

10
n8n/Dockerfile.runner Normal file
View File

@@ -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