# node:module

The `node:module` module gives access to the Node.js module system, which covers CommonJS and ES modules, as the [Node.js module documentation](https://nodejs.org/api/module.html) 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:

```javascript
/**
 * An example of using the Node.js Module API in an Azion Function.
 * @example
 * // Build and run locally with the Azion CLI:
 * azion build
 * azion dev
 */
import module from "node:module";

/**
 * An example of using the Node.js Module API in an Azion Function.
 * @param {*} event
 * @returns {Promise<Response>}
 */
const main = async (event) => {
  return new Promise((resolve, reject) => {
    module.builtinModules.forEach((moduleName) => {
      console.log(moduleName);
    });
    resolve(new Response("Done"));
  });
};

export default main;
```

The function logs the 65 names, one per line, from `_http_agent` to `zlib`, and responds with this body:

```text
Done
```

---

## Related resources

- [Node.js APIs](/en/documentation/devtools/runtime/node.md): Every Node.js module Azion Runtime resolves, and how each one behaves.
- [Use Node.js APIs through polyfills](/en/documentation/guides/application-development/functions-and-runtime/use-polyfills.md): How the build resolves Node.js APIs through polyfills, shown in a JavaScript project.
- [Azion CLI build](/en/documentation/devtools/cli/build.md): The command that builds a project on your machine and writes the result to the `.edge` folder.
- [Handlers](/en/documentation/devtools/runtime/api-reference/handlers.md): The recommended handler shape, and the notice `azion build` prints for the `export default main` shape this sample uses.
