module

A file of code whose functions, classes and variables other files can use by importing it.

In more detail

Each module has its own scope, so names defined in one file do not clash with names in another. Splitting a program into modules keeps each file focused and gives the parts clear boundaries. The language's module system decides how one file names another and when that file is loaded.

Example

Node.js has two module systems: CommonJS, using require(), and ECMAScript modules, using import; built-in modules use a node: prefix, such as node:fs.

Related terms

Taught in

References

Certification courses