Transitioning to ESM from CommonJS - requires at least Node.js v20

I was just catching up on the status of Node.js ESM/CJS compatibility.

I now see that the the integration has been back-ported all the way to Node.js v20 - but not v18. And also v18 is already end of life.

So are there plans to release a Node-RED v5 soon so that node developers can begin to use the ESM/CJS integration to begin transitioning to ESM? That would, of course, also enable Node-RED core to also start to transition.

At the moment, we're on the cusp of 4.1-beta (days away). There is a case to be made for this to actually be 5.0; however, there are some other potentially breaking changes for 5.0 that we don't have the bandwidth for currently and I wouldn't want to delay getting non-breaking changes released because of that.

Once we have 4.1 out of the way, we'll refocus onto 5.0 soon after.

Hi Nick, thanks for the rapid response.

At risk of being a pain (as usual!), could I ask that you rethink whether 4.1 could be 5 with the only breaking change being the uplift of node.js to the current node.js v20 LTS?

It would open a load of possibilities.

That would then push back the opportunity for other potential breaking changes by a year.

What possibilities are you wanting to unlock? You know you can set an 'engines' property in your module to require Node 20? Not perfect, but would bridge the gap.

I would really like to start working on moving my nodes from CJS to ESM so that I can eliminate some final dependencies and to standardise on ESM so I don't keep having to waste energy mentally converting and working round integration issues.

But even more importantly I would think would be the ability for contributors to core to start work on the move to ESM.

And if you would relax the node checker rules to allow nodes to be the current node.js OR ABOVE, then that would meet the needs for my own nodes anyway.

Actually, I'm not sure it would - unless there is a clear way to write a node as a Module - and I'm not sure that is yet possible?

I have a use case where I used esbuild to output esm and it didnt work, even with node 22. The build runs without any issues, but as soon as one of my nodes receives a message an error saying something "dynamic import blablabla does not work" was thrown. I had to fallback to cjs. The issue was comming from an esm only package "aws-cdk-lib"