Skip to content

Small demo to document differences between es6 and nodejs imports

Notifications You must be signed in to change notification settings

aurelius0523/es6-vs-node-import

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Overview

nodejs

  • require and module.exports are nodejs keywords, not javascript
  • when using nodejs native keywords, there is no need to include 'type': module in package.json

javascript (es6)

  • import and export are javascript keywords, not nodejs.
  • Therefore you'll need to set 'type': module in package.json

commonjs

  • commonjs is already incorporated inside Nodejs, where the keywords module.exports and require are used:

    const myModule = require("store/customer");
    function main() {
      myModule.listCustomer();
    }
    
    module.exports = main;

About

Small demo to document differences between es6 and nodejs imports

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published