Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions doc/api/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -2858,6 +2858,31 @@ console.log(memoryUsage.rss());
// 35655680
```

## `process.loadedModules`

<!-- YAML
added: v0.5.3
-->

* Type: {string\[]}

The `process.loadedModules` property returns an array of core modules that
were loaded during the current Node.js process execution.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small wording nit: "process execution" feels slightly redundant. "during the current process" might be cleaner.

  • that were loaded during the current Node.js process execution.
  • that were loaded during the current process.


```mjs
import { loadedModules } from 'node:process';

console.log(loadedModules);
// ['events', 'buffer', 'diagnostics_channel', 'async_hooks', ...]
```

```cjs
const { loadedModules } = require('node:process');

console.log(loadedModules);
// ['events', 'buffer', 'diagnostics_channel', 'async_hooks', ...]
```

## `process.nextTick(callback[, ...args])`

<!-- YAML
Expand Down
11 changes: 11 additions & 0 deletions lib/internal/bootstrap/realm.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@
writable: false,
});

// Set up process.loadedModules
const loadedModules = [];
ObjectDefineProperty(process, 'loadedModules', {
__proto__: null,
get() { return ArrayPrototypeSlice(loadedModules); },
configurable: true,
enumerable: true,
})

Check failure on line 90 in lib/internal/bootstrap/realm.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Missing semicolon

// processBindingAllowList contains the name of bindings that are allowed
// for access via process.binding(). This is used to provide a transition
Expand Down Expand Up @@ -405,6 +413,9 @@
// "NativeModule" is a legacy name of "BuiltinModule". We keep it
// here to avoid breaking users who parse process.moduleLoadList.
ArrayPrototypePush(moduleLoadList, `NativeModule ${id}`);
if(!StringPrototypeStartsWith(id, 'internal/')) {

Check failure on line 416 in lib/internal/bootstrap/realm.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected space(s) after "if"
ArrayPrototypePush(loadedModules, id);
}
return this.exports;
}
}
Expand Down
Loading