n8n · infra · fg-0343

n8n Code node throws 'Cannot find module' for an npm package installed in the n8n image

Cannot find module 'word-extractor' with a require stack under @n8n/task-runner

Verified 2026-10-15 · Confirmed by 0 builders · Trust 50/100

Cause

Code now runs inside task runners, which have their own node_modules and a locked allowlist file. Packages and allowlists set on the main n8n container do not reach the runner.

Fix

Build a custom image from n8nio/runners with the packages installed, allowlist them in n8n-task-runners.json under env-overrides, and mount it at /etc/n8n-task-runners.json.

Apply

ARG N8N_VERSION
FROM n8nio/runners:${N8N_VERSION}
USER root
RUN cd /opt/runners/task-runner-javascript && pnpm add word-extractor
COPY n8n-task-runners.json /etc/n8n-task-runners.json
USER runner
# n8n-task-runners.json, javascript runner env-overrides: "NODE_FUNCTION_ALLOW_EXTERNAL": "word-extractor"

Affects: n8n 2.0 and later (runners on by default), and 1.x with N8N_RUNNERS_ENABLED=true; custom runner images need n8nio/runners 1.121.0 or later

Sources

Have your agent know this before it fails

claude mcp add --transport http footgun https://getfootgun.com/api/mcp