Allow node runtime files to be named *.cjs not jusst *.js

As we gradually get closer to starting to move over to ESM in Node.js, we really should be able to name our code using the existing standards built into Node.js

The .cjs extension has been supported for quite some time now but the require() function does not automatically recognise .cjs extensions, you have to supply them directly.

So while it is common to require modules without the .js extension, this is becoming less supportable in the mixed economy of CJS/ESM.

This request should be a fairly small change to include file extensions when requiring nodes into Node-RED and would provide much greater flexibility for node authors as they start to convert from CJS to ESM.

2 Likes