# Node.JS require(es-module) for Node-RED v5?

**URL:** <https://discourse.nodered.org/t/node-js-require-es-module-for-node-red-v5/100257>\
**Category:** Feature Requests\
**Created:** [27 January 2026 16:39 UTC](https://discourse.nodered.org/t/node-js-require-es-module-for-node-red-v5/100257 "2026-01-27T16:39:36Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [27 January 2026 16:39 UTC](https://discourse.nodered.org/t/node-js-require-es-module-for-node-red-v5/100257/1 "2026-01-27T16:39:36Z")

</div>

Hi, apologies if this has already been covered and I missed it.

I would be absolutely amazing in the v5 release of Node-RED could be linked to node.js v26 as a baseline.

Why? Because `require(esm)` has now landed as live in v25.4.0 which means that it will be live in the next ESR release, v26. `require(esm)` should allow greater flexibility for node creators to start using ESM in earnest for developing nodes I believe.

Not had a chance to test this myself yet, I don't currently have an available test environment where I can run node.js v25 and node.js v5.

Anyway, 🤞and hoping for node.js v26. It is due to be released in April so not sure if this fits in with the v5 release schedule.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [27 January 2026 17:02 UTC](https://discourse.nodered.org/t/node-js-require-es-module-for-node-red-v5/100257/2 "2026-01-27T17:02:22Z")

</div>

I'm hoping NR5 will be stable long before April - don't really want to delay it unnecessarily.

Node 24 is the targeted default version.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [27 January 2026 17:07 UTC](https://discourse.nodered.org/t/node-js-require-es-module-for-node-red-v5/100257/3 "2026-01-27T17:07:51Z")

</div>

OK, fair enough - here's hoping for a rapid delivery of node-red v6 then. 😃

It is getting increasingly hard to find node.js tools that aren't going ESM-only which certainly complicates some integrations with Node-RED.

I've not yet found a realistic way to write nodes as ES Modules without a build step which certainly not only adds build complexity but also debugging complexity.

Perhaps others more knowledgeable that me will find a way.

---

<div class="post-metadata">

**Author:** ![omrid](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@omrid](https://discourse.nodered.org/u/omrid)\
**Post date:** [27 January 2026 21:47 UTC](https://discourse.nodered.org/t/node-js-require-es-module-for-node-red-v5/100257/4 "2026-01-27T21:47:20Z")

</div>

hasn't ESM been implemented experimentally and backported into current Node.JS?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [28 January 2026 00:11 UTC](https://discourse.nodered.org/t/node-js-require-es-module-for-node-red-v5/100257/5 "2026-01-28T00:11:44Z")

</div>

Oops, I missed that! You are right, though you need v22.12.0+. Confusing that node.js claimed it for v25 without a reminder about v22/v24.

In either case, only ESM's without top-level await's are allowed.

Last time I tried, can't really remember when that was, you couldn't write a node runtime as an ESM - clearly, _I need to try again_.

I've already moved most Editor code in uibuilder to modules.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [28 January 2026 12:45 UTC](https://discourse.nodered.org/t/node-js-require-es-module-for-node-red-v5/100257/6 "2026-01-28T12:45:40Z")

</div>

OK, so I have created a new node in my testbed. I've verified that the node is correctly registered and appears in the palette **if it is a CommonJS runtime module**.

If I change it to a an ES Module, it says that it has correctly registered but **it does not appear in the palette**.

I would be grateful for any ideas on how to progress on this. Feels like we are close but something is missing.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [28 January 2026 13:11 UTC](https://discourse.nodered.org/t/node-js-require-es-module-for-node-red-v5/100257/7 "2026-01-28T13:11:33Z")

</div>

We have this pending PR that claims to add support for ESM models. It's been on the backlog for some time, but had some recent activity and we'll look at adding it for NR5 (maybe backport to NR4 stream at a push).

Maybe kick the tyres of that to see if it helps?

> <https://github.com/node-red/node-red/pull/4355>
>
> \- \[x\] Bugfix (non-breaking change which fixes an issue)
> \- \[\] New feature (non-…breaking change which adds functionality)
> 
> \## Proposed changes
> 
> Currently node-red fails when attempting to install a node written as an ESM module, e.g.
> 
> \`\`\`text
> 19 Sep 18:59:53 - \[info\] Server now running at http://127.0.0.1:1880/
> 19 Sep 18:59:53 - \[info\] Starting flows
> 19 Sep 18:59:53 - \[info\] Started flows
> 19 Sep 19:01:05 - \[info\] Installing module: @hlovdal/node-red-lowercase-in-typescript, version: 1.0.0
> 19 Sep 19:01:12 - \[info\] Installed module: @hlovdal/node-red-lowercase-in-typescript
> 19 Sep 19:01:12 - \[info\] Added node types:
> 19 Sep 19:01:12 - \[info\] - @hlovdal/node-red-lowercase-in-typescript:lower-case : Error \[ERR\_REQUIRE\_ESM\]: require() of ES Module .../.node-red/node\_modules/@hlovdal/node-red-lowercase-in-typescript/src/lower-case.js from .../node-red/packages/node\_modules/@node-red/registry/lib/loader.js not supported.
> Instead change the require of lower-case.js in .../node-red/packages/node\_modules/@node-red/registry/lib/loader.js to a dynamic import() which is available in all CommonJS modules.
> \`\`\`
> 
> This pull request fixes that by using \[dynamic \`import()\`\](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) instead of \`require\`.
> 
> \## Checklist
> 
> \- \[x\] I have read the \[contribution guidelines\](https://github.com/node-red/node-red/blob/master/CONTRIBUTING.md)
> \- \[x\] For non-bugfix PRs, I have discussed this change on the \[forum\](https://discourse.nodered.org/t/adding-support-for-installing-esm-module-nodes/81438)/slack team.
> \- \[x\] I have run \`npm run test\` to verify the unit tests pass
> \- \[\] I have added suitable unit tests to cover the new/changed functionality

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [28 January 2026 13:38 UTC](https://discourse.nodered.org/t/node-js-require-es-module-for-node-red-v5/100257/8 "2026-01-28T13:38:44Z")

</div>

OK, try manually replacing the code in the PR into my dev instance.

There is an error in the code in that `let importPromise = import(node.file);` does not reliably work because imports have to be URL's, not file paths. Kind-of works probably on Linux but certainly not on Windows.

I'll leave a comment on the PR for the fix.

However, sadly, this does not fix the issue of the module not appearing in the editor.

So I would say that, as long as you assume that NR v5 will use the LTS version of node.js v24, the PR is unnecessary since `require` loads _MOST_ ESM's anyway - just so long as they don't have a top-level `await`.

Any clues as to where I could find some NR code where the nodes are added to the palette? I could maybe trace the issue there.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [28 January 2026 15:01 UTC](https://discourse.nodered.org/t/node-js-require-es-module-for-node-red-v5/100257/9 "2026-01-28T15:01:26Z")

</div>

Tried again, this time with the lower-case node example to keep things as simple as possible.

Played with a number of combinations and I've found one that works.

While Node-RED is happy loading a module `something.cjs` or `something.mjs`, when loading `something.mjs` - the module is not added to the palette.

But if you rename to `something.js` - it works.

So there is a small bug in the core code somewhere. In fact, didn't we come across this a while back - I vaguely remember reporting an issue - ah yes, [loader.js cannot handle \*.cjs files · Issue #5220 · node-red/node-red · GitHub](https://github.com/node-red/node-red/issues/5220)

The fix for that issue only implemented \*.cjs file handling. I would suggest that, at least for v5, \*.mjs file handling should also be accommodated.

* * *

I've done some quick tests having manually updated the previous fix with additions for \*.mjs and it works as expected.

I've only tested with node.js v24 though. v22.12+ should also work as expected. I don't think node-red's v4 baseline of v18 will work?

---

<div class="post-metadata">

**Author:** ![AllanOricil](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/allanoricil/32/106911_2.png) [@AllanOricil](https://discourse.nodered.org/u/AllanOricil)\
**Post date:** [10 February 2026 00:06 UTC](https://discourse.nodered.org/t/node-js-require-es-module-for-node-red-v5/100257/10 "2026-02-10T00:06:01Z")

</div>

My framework and plugin allows devs to author nodes using ESM, including importing es modules. Then it builds to commonjs.

> **[GitHub - AllanOricil/node-red-vue-template at wip\_ts](https://github.com/AllanOricil/node-red-vue-template/tree/wip_ts)**
>
> wip\_ts

Im about to release core and vite as standalone packages, and update nrg to use this new template.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [10 February 2026 00:42 UTC](https://discourse.nodered.org/t/node-js-require-es-module-for-node-red-v5/100257/11 "2026-02-10T00:42:49Z")

</div>

> [@AllanOricil](#):
>
> using ESM, including importing es modules. Then it builds to commonjs.

Doing ESM based node runtimes with a build step is easy enough - though the issue there is that error reporting can end up pointing to things that are not human comprehensible without running under node.js with source maps enabled.

Once Node-RED v5 is released, we can move the baseline node.js version up and then, as I've shown, as long as you avoid using top-level async, you will be able to write node runtimes as ESM's natively with no build step.

Using ESM for the Editor code has always worked as long as you use a browser that supports ESM's. Really not a problem as all browsers have supported them for ages now.

There are already many node.js libraries and packages that only support ESM so this is a really important change for Node-RED since otherwise, it would be in real danger of becoming obsolete.

---

<div class="post-metadata">

**Author:** ![AllanOricil](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/allanoricil/32/106911_2.png) [@AllanOricil](https://discourse.nodered.org/u/AllanOricil)\
**Post date:** [10 February 2026 00:58 UTC](https://discourse.nodered.org/t/node-js-require-es-module-for-node-red-v5/100257/12 "2026-02-10T00:58:07Z")

</div>

esbuild + rollup

 ![17706850743514310647680351861565](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/f/cfc800d92c3a31ee4892567ec9164e9b1d2814e7.jpeg)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [11 April 2026 00:58 UTC](https://discourse.nodered.org/t/node-js-require-es-module-for-node-red-v5/100257/13 "2026-04-11T00:58:32Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
