Node.js LTS version 14, released Oct 27, 2020, finally supports ES6 modules with the import/export syntax. You can convert all the files in a node project to modules by specifying the type field in package.json
// package.json
{ "type": "module" }
Or change the extension of the files from .js to .mjs (both importing and exporting files).
Then use the import/export syntax in place of module.exports/require()
This apparently doesn't work with the Jest testing framework. It still treats all files as commonjs and throws errors wherever import/export statements are placed. Has Jest just not caught up with this development in Node or is there some way to make it work without the overhead of adding babel?