Describe the problem/error/question
After following the instructions on how to install custom npm/Python packages in the docker runner, the JS package cannot actually be used in the Code node.
The instructions are for n8n v1 and I’m running v2. If works for Python, but not for npm packages.
I also opened a ticket here, but it was closed without actually solving it, so I posted it here again.
What is the error message (if any)?
Cannot assign to read only property ‘constructor’ of object ‘Error’
Please share your workflow
The docker compose installs the necessary custom packages, a Puppeteer instance is also needed:
services:
n8n:
image: n8nio/n8n
restart: unless-stopped
environment:
- N8N_RUNNERS_MODE=external
- N8N_BLOCK_ENV_ACCESS_IN_NODE=false # Allow $env in "Code" node.
- N8N_RUNNERS_BROKER_LISTEN_ADDRESS=0.0.0.0
- N8N_RUNNERS_AUTH_TOKEN=${N8N_RUNNERS_AUTH_TOKEN}
- BROWSERLESS_TOKEN=${BROWSERLESS_TOKEN}
volumes:
- ./n8n:/home/node/.n8n
ports:
- 5678:5678
n8n-runners:
build:
context: .
dockerfile_inline: |
FROM n8nio/runners:stable
USER root
RUN cd /opt/runners/task-runner-javascript && pnpm add puppeteer-core
USER runner
environment:
- N8N_RUNNERS_TASK_BROKER_URI=http://n8n:5679
- N8N_RUNNERS_AUTH_TOKEN=${N8N_RUNNERS_AUTH_TOKEN}
- N8N_RUNNERS_LAUNCHER_LOG_LEVEL=debug
- N8N_RUNNERS_INSECURE_MODE=true
volumes:
- ./n8n-runners/n8n-task-runners.json:/etc/n8n-task-runners.json
depends_on:
- n8n
browserless:
image: ghcr.io/browserless/chromium
restart: unless-stopped
environment:
- TOKEN=${BROWSERLESS_TOKEN}
The mounted n8n-task-runners.json file contains the following:
{
"task-runners": [
{
"runner-type": "javascript",
"workdir": "/home/runner",
"command": "/usr/local/bin/node",
"args": [
"--disallow-code-generation-from-strings",
"--disable-proto=delete",
"/opt/runners/task-runner-javascript/dist/start.js"
],
"health-check-server-port": "5681",
"allowed-env": [
"PATH",
"GENERIC_TIMEZONE",
"NODE_OPTIONS",
"N8N_RUNNERS_AUTO_SHUTDOWN_TIMEOUT",
"N8N_RUNNERS_TASK_TIMEOUT",
"N8N_RUNNERS_MAX_CONCURRENCY",
"N8N_SENTRY_DSN",
"N8N_VERSION",
"ENVIRONMENT",
"DEPLOYMENT_NAME",
"HOME"
],
"env-overrides": {
"NODE_FUNCTION_ALLOW_BUILTIN": "*",
"NODE_FUNCTION_ALLOW_EXTERNAL": "*",
"N8N_RUNNERS_HEALTH_CHECK_SERVER_HOST": "0.0.0.0"
}
},
{
"runner-type": "python",
"workdir": "/home/runner",
"command": "/opt/runners/task-runner-python/.venv/bin/python",
"args": [
"-I",
"-B",
"-X",
"disable_remote_debug",
"-m",
"src.main"
],
"health-check-server-port": "5682",
"allowed-env": [
"PATH",
"N8N_RUNNERS_LAUNCHER_LOG_LEVEL",
"N8N_RUNNERS_AUTO_SHUTDOWN_TIMEOUT",
"N8N_RUNNERS_TASK_TIMEOUT",
"N8N_RUNNERS_MAX_CONCURRENCY",
"N8N_SENTRY_DSN",
"N8N_VERSION",
"ENVIRONMENT",
"DEPLOYMENT_NAME"
],
"env-overrides": {
"N8N_RUNNERS_STDLIB_ALLOW": "*",
"N8N_RUNNERS_EXTERNAL_ALLOW": "*"
}
}
]
}
This is the n8n workflow definition:
Share the output returned by the last node
The error is displayed. Possibly related to an import issue, but not sure.
Information on your n8n setup
- n8n version: 2.11.2
- Database (default: SQLite): SQLite
- n8n EXECUTIONS_PROCESS setting (default: own, main): main
- Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
- Operating system: mac OS Tahoe 26.2