We recently updated from 1.123.6 to 1.123.61. We are having a OTEL workflow to track custom metrics which uses the code node and the internally used prom-client library like so const client = require('prom-client');. This does not work anymore due to the error “Cannot find module ‘prom-client’”. We enabled N8N_METRICS and also set NODE_FUNCTION_ALLOW_EXTERNAL to "prom-client". This worked in 1.123.6. Is this a regression or a breaking change?
You can modify your Start Command on Render to install the package before starting n8n:
npm install prom-client && n8n start
Else you can pin your Docker image version back to 1.123.6 until a fix is released.
If you choose to open a GitHub issue, you can categorize it as a Regression.
Version affected: 1.123.61
Working version: 1.123.6
Environment: Docker
Issue: prom-client is no longer hoisted to the root node_modules, breaking require('prom-client') in Code nodes despite NODE_FUNCTION_ALLOW_EXTERNAL being set.
This issue is a side effect of recent dependency bundling and package refactoring updates in n8n, rather than an intentional breaking change to the Code node.
Why it stopped working:
Previously, prom-client was present as an unbundled, top-level dependency in n8n’s root node_modules. Setting NODE_FUNCTION_ALLOW_EXTERNAL=prom-client allowed the Code node to resolve n8n’s internal copy. In recent releases, n8n updated its internal package structure/bundler (isolating internal dependencies), so prom-client is no longer exposed directly in the root node_modules directory for Node’s module resolver to find.
Relying on n8n’s internal sub-dependencies via require() can break across version updates when internal packages move around.
How to fix it (Since you are running via Docker on Render.com):
The permanent solution is to explicitly install prom-client as an external module in your Docker container so Node.js can always resolve it.
Fix 1: Custom Dockerfile (Recommended)
If you deploy via a Dockerfile on Render, update your Dockerfile to install prom-client explicitly:
FROM n8nio/n8n:1.123.61
USER root
# Install prom-client globally so Code node can require it
RUN npm install -g prom-client
USER node
# Ensure NODE_PATH includes global modules
ENV NODE_PATH=/usr/local/lib/node_modules
Make sure your environment variable remains set:
NODE_FUNCTION_ALLOW_EXTERNAL=prom-client
Fix 2: Render Startup Command (Alternative)
If you are running the official n8nio/n8n image directly on Render without a custom Dockerfile, you can add a start script or command override before starting n8n:
cd /home/node/.n8n && npm install prom-client && n8n start
Once prom-client is explicitly installed in the container environment, your Code node’s const client = require(‘prom-client’) , will work smoothly again!
@Florian_Glappa can you share your full setup including how you are installing the npm package. Are you also using task runners as that will change things.
I do not install the npm package, as the docs say, n8n is using the package internally, I just hooked into that functionality with the two env vars I mentioned in the post.
@Florian_Glappa I have done some digging and it looks like it stopped working in 1.123.42 but it appears to be working again in the current latest beta release so it could be that a v2 update would be worth doing if possible.
I have however created N8N-10510 as a dev ticket to also see if we can get this fixed.
Thanks alot for digging into this. A v2 update needs research regarding breaking changes, thats not possible for us right now. So looking forward to N8N-10510
I see it is already merged and released in 1.123.66, thats great! Unfortunately there are only amd and arm Docker images of this version, not the generic one. I guess I need to wait for that?