From afe4f5617962ec0ddcd95cd1f3485cf864d08281 Mon Sep 17 00:00:00 2001 From: Xavier Stouder Date: Fri, 9 Jan 2026 22:27:04 +0100 Subject: [PATCH] lib: add `process.loadedModules` list Add a new `process.loadedModules` property that returns an array of public core module names that have been loaded during the current Node.js process execution. This provides a cleaner, documented API for accessing loaded module information compared to the undocumented `process.moduleLoadList`. Fixes: https://github.com/nodejs/node/issues/41233 Refs: https://github.com/nodejs/node/pull/61276 --- doc/api/process.md | 24 +++++++++++++++++++++ lib/internal/bootstrap/realm.js | 12 +++++++++++ test/parallel/test-process-loadedmodules.js | 7 ++++++ 3 files changed, 43 insertions(+) create mode 100644 test/parallel/test-process-loadedmodules.js diff --git a/doc/api/process.md b/doc/api/process.md index 04ca0eff9c55d4..9cb77bf515d4fd 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -2696,6 +2696,30 @@ process.kill(process.pid, 'SIGHUP'); When `SIGUSR1` is received by a Node.js process, Node.js will start the debugger. See [Signal Events][]. +## `process.loadedModules` + + + +* Type: {string\[]} + The `process.loadedModules` property returns an array of core modules that + were loaded during the current Node.js process execution. + +```mjs +import process from 'node:process'; + +console.log(process.loadedModules); +// ['events', 'buffer', 'diagnostics_channel', 'async_hooks', ...] +``` + +```cjs +const process = require('node:process'); + +console.log(process.loadedModules); +// ['events', 'buffer', 'diagnostics_channel', 'async_hooks', ...] +``` + ## `process.loadEnvFile(path)`