How can I use an ES6 import in Node.js? [duplicate]

Node.js has included experimental support for ES6 support. Read more about here: https://nodejs.org/docs/latest-v13.x/api/esm.html#esm_enabling. TLDR; Node.js >= v13 It’s very simple in Node.js 13 and above. You need to either: Save the file with .mjs extension, or Add { “type”: “module” } in the nearest package.json. You only need to do one of the above to … Read more