Open In App

How to use EcmaScript modules in Node.js ?

CommonJS modules consists usage of exports and require() statements, while EcmaScript modules consists usage of import and export statements.

Learn more here: Difference between node.js require and ES6 import and export



Node.js treats JS code as CommonJS modules by default, However the EcmaScript modules can be used instead of using –experimental-modules flag.

Follow the below mentioned Steps:



Output:

Article Tags :