Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Lesson 32: Modules: require & exports

Split code across files with CommonJS.

What you'll learn

  • export with module.exports = ... or exports.x = ...
  • import with const x = require('./file')
  • each file is its own module (own scope)
  • ESM alternative: import/export with "type": "module"

Example

See examples/.

Exercise

Split a 50-line file into 3 modules.