4 ms·
> the last 2 LTS releases of Node (Author here.) Node 14 supports ESM, but Node 12 only supports ESM behind the --experimental-modules flag, and its error han
by dfabulich 6y ago
> the last 2 LTS releases of Node
(Author here.)
Node 14 supports ESM, but Node 12 only supports ESM behind the --experimental-modules flag, and its error handling for incorrectly importing CJS is not good.
In 2020, I think it's a bit early to go ESM only, especially since it's straightforward for CJS libraries to support both CJS and ESM clients. (I document how to do this in the article.)
- colinr 6y agoThe experimental flag was recently removed in v12.17.0 (though the release notes still say ESM is an experimental feature) https://github.com/nodejs/node/releases/tag/v12.17.0 https://github.com/nodejs/node/releases/tag/v12.17.0