node:module
The node:module module in Azion Runtime: what its members return inside a function, and a sample that lists the built-in module names.
The node:module module gives access to the Node.js module system, which covers CommonJS and ES modules, as the Node.js module documentation describes. In Node.js, the module system organizes code into reusable files and libraries. In Azion Runtime, import module from "node:module" builds, and you use it to inspect the module system, for example to list the built-in modules a function can import.
The members below behave the same in a deployed function and under azion dev. module.builtinModules is an array of 65 names, from _http_agent to zlib. module.createRequire() returns undefined instead of a require function, so a call to its result throws a TypeError. module.isBuiltin() does not exist. SourceMap, _findPath, _initPaths, _load, _nodeModulePaths, _preloadModules, _resolveFilename, and _resolveLookupPaths are not supported.
Example
The function below logs the name of every built-in module and responds when the list ends:
The function logs the 65 names, one per line, from _http_agent to zlib, and responds with this body: