Core Modules

I. Node Core Modules

Core modules come with Node.js and don’t need to be installed. They provide low-level functionality and helper methods.

Core modules allow Node.js to work with the filesystem, networking, binary data, streams, spawn external processes, parse query strings, file paths and URLs, and perform other helpful tasks such as creating HTTP(S) agents/clients and servers.

II. Main core modules

List of main core modules:

  • fs: module to work with the file system, files and folders
  • path: module to parse file system paths across platforms
  • querystring: module to parse query string data
  • net: module to work with networking for various protocols
  • stream: module to work with data streams
  • events: module to implement event emitters (Node observer pattern)
  • child_process: module to spawn external processes
  • os: module to access OS-level information including platform, number of CPUs, memory, uptime, etc.
  • url: module to parse URLs
  • http: module to make requests (client) and accept requests (server)
  • https: module to do the same as http only for HTTPS
  • util: various utilities including promosify which turns any standard Node core method into a promise-base API
  • assert: module to perform assertion based testing
  • crypto: module to encrypt and hash information

III. Include core modules

There is no need to install or download core modules.

To include them in your application, use require() and enter the module/package name as the name string.

For example, the following code imports a package named http.

const http = require('http') //replace `http` with the core module you want to use

The package is in

  • the node_modules folder in the root of the project if it’s an installed npm package
  • the system folder if it’s a core Node module (location depends on your OS and how you installed Node)