Update from 1.123.6 to 1.123.61 -> using prom-client in code node broken

Describe the problem/error/question

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?

Please share your workflow

Share the output returned by the last node

[
{
“name”: “n8n_learning_progress_achievement_sync_total”,
“description”: “Number of learning progress syncs from achievement webhook”,
“values”: {
“academy”: “faps-fernstudium”,
“testStatus”: “passed”,
“assignment”: 17392228439111
},
“error”: “Cannot find module ‘prom-client’ [line 1, for item 0]”
}
]

Information on your n8n setup

  • n8n version: 1.123.61
  • Database (default: SQLite): Postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main): own, main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker on render.com
  • Operating system:

@Florian_Glappa

This seems like a regression.

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.

Hi @Florian_Glappa ,

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!

Thanks!

@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 Just to double check was it 1.123.6 or 1.123.60 before you updated and are you using external task runners?

It could be that some of the recent hardening steps are preventing the package from loading.

It was 1.123.6. I do not use external task runners.

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

It may be worth keeping in mind that v1 will be EoL before the end of the year so it may be worth starting to plan for that.

On this issue though… fix(Code Node): External modules not working even when allowed in n8n version 1.x by RomanDavydchuk · Pull Request #34093 · n8n-io/n8n · GitHub has been created so it should be all good before the end of the week.

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?

New version n8n@1.123.66 got released which includes the GitHub PR 34093.

We have only had the 2 images for a long time, Which one were you using?