How to Use ES6 Imports in Node.js

You can learn how to Node.js’s ES6 “import” statements at this Stack Overflow URL.

In short, there are two (2) ways:

  • Save the file with an *.mjs extension, or
  • Add { "type": "module" } in the nearest package.json