n8n · infra · fg-0343

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

If you see Cannot find module 'word-extractor' with a require stack under @n8n/task-runner, the cause and the fix for n8n are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
Cannot find module 'word-extractor' with a require stack under @n8n/task-runnerNODE_FUNCTION_ALLOW_EXTERNAL set on the main container has no effectWorked in an image before task runners were enabled
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"
Affected
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

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun