1. Home
  2. Node
  3. Require module
#node#module

Require is a Node specific function letting you add exported functionality and/or data from other modules. The function takes an argument for the module location. The ".js" file extension is optional. It's also a good practice to use constants when assigning required modules.

const settings = require('./settings.js');
// This works the same way
const settings = require('./settings');
copy
Full Node cheatsheet
Sitemap Git repository