Using ES Modules in Node.js
View on Twitter
💡 In Node.js, you can use native ES Modules in two ways:
👉🏼 By using the ".mjs" extension or adding "type": "module" to your package.json.
❗️ Available from Node.js 13.2 and up.
![Two ways to use ESM: 1. Use .mjs file extension, or 2. Add type: module to your package.json.](/images/tips/using-esmodules-in-nodejs.jpg)
💡 In Node.js, you can use native ES Modules in two ways:
👉🏼 By using the ".mjs" extension or adding "type": "module" to your package.json.
❗️ Available from Node.js 13.2 and up.