Before Node version 13, we were using the esm npm package and run our app.js using the commandnode -r esm app.js

With recent updates of Node, this is natively supported now. There are two ways we can achieve it

  • Save the file with .mjs extension.
  • Add { "type": "module" }