Skip to content
skillbld
Node.js · 14-day planAll days
Day 2 of 14 30 min

Split a program into files. Learn CommonJS (require and module.exports) and ES modules (import and export), how Node finds modules, the built-in modules with the node prefix, and how to choose between the two systems.

By the end of today you can

  • Export and import code with CommonJS
  • Export and import code with ES modules
  • Use built-in modules with the node prefix
  • Explain how Node resolves a module path and caches modules
  • Choose between CommonJS and ES modules for a project

What's inside

  • 5 sections
  • 3 diagrams and mind maps
  • 5 code examples you can run
  • 5-question quiz
  1. 1CommonJS: require and module.exports
  2. 2Modules are cached
  3. 3ES modules: import and export
  4. 4Built-in modules
  5. 5How Node finds a module

Sign in free to read this lesson

Get the full lesson with diagrams, runnable code and the quiz. Your progress is saved across devices.

Sign in free

Keep going

Day 2: Modules · Node.js · SkillBld