Require

Verb · Development

Definitions

  1. The synchronous module-loading function in Node.js's CommonJS module system that reads a file, executes it, caches the resulting exports object, and returns it. Largely supplanted by ES module import syntax but still ubiquitous in existing Node.js codebases and configuration files.

    In plain English: The original way to load other code files in Node.js, like an #include that runs the file and gives you back whatever it exported.

    Example: "The config file uses require() because Jest and Webpack configs still default to CommonJS — ES modules there are opt-in."

Related Terms