Lesson 6 / 28

Built-in, Third-Party & Local Modules

Three sources every require/import can pull from.

Three kinds of modules

Built-in modules ship with Node (fs, path), third-party modules come from npm (express), and local modules are your own files (./utils.js).

Telling them apart

The specifier tells Node where to look: a bare name, or a relative path.

import fs from "node:fs";        // built-in
import express from "express";   // third-party (node_modules)
import { add } from "./math.js"; // local file

Quick check: Which prefix explicitly marks a Node built-in module?

  • node:
  • npm:
  • ./
Answer

node: — `node:fs`, `node:path` etc. make it unambiguous that you mean the built-in, not a same-named package.