Module in NodeJS and ES6
Jul 28, 2017 · 1 min read

Modules are frequently used techniques which is an important part of decoupling and make the code more readable and organised.
Module in NodeJS
In NodeJS, keywords module, exports and required are exploited to create/import a module. Here are three ways of creating a module. Some examples:
Module in ES6
In ES6, we can export constant, function, class as modules:
- export
constant - export
function - export
class
However, import keyword is from ES6, but not natively supported by NodeJS yet, so in order to make the following code work, we use babel to compile it first.
Reference
