CCA Prep

Lesson 6.3Lesson 22 of 24

Core modules and common libraries

Know the core Node.js modules and given requirements, infer which Node.js library/framework is a good solution.

Core modules and common librariesBuilt in: require('name')fs · fs/promises · pathhttp · url · osevents · util · child_process ·streamInstalled from npmExpressJest · Mochanodemon · dotenvReach for a core module first; add a library when it saves real work

Key points

  1. 1Files: fs for callbacks and streams, fs/promises for await. Paths: path.join glues segments, path.resolve builds an absolute path.
  2. 2http creates a server or sends requests; url gives the WHATWG URL class; os describes the machine, for example os.cpus().
  3. 3events provides EventEmitter; util.promisify turns an (err, value) callback function into one that returns a promise.
  4. 4child_process runs other programs: exec buffers the whole output, spawn streams it.
  5. 5Express is a framework on top of http that adds routing and middleware. Pick a library by its purpose, not by its popularity.
What the exam guide checks here

Objective wording from the exam guide (English).

  • 6.3.K1Core modules: fs, path, http, events, os, url, util, child_process
  • 6.3.K2Widely used libraries and frameworks and what each is for (e.g. Express)
  • 6.3.S1Choose the module or library that meets a requirement

Lock it in

Answer scenario questions on this topic. Every option comes with an explanation.

Practise 6.3 · 12 questions