This recipe migrates code from the deprecated repl.builtinModules and repl._builtinLibs properties to the stable module.builtinModules API.
Deprecation
Node.js deprecated repl.builtinModules and repl._builtinLibs in favor of module.builtinModules.
See DEP0191 and DEP0142 for more details.
Usage
Run this codemod with:
Before/After
What It Does
- Replaces
repl.builtinModules with module.builtinModules
- Replaces
repl._builtinLibs with module.builtinModules
- Updates imports from
node:repl to node:module when appropriate
- Works with both ESM and CommonJS patterns
Common Use Cases
Listing Built-in Modules
Checking if Module is Built-in
The property repl._builtinLibs was always a private API (prefixed with _). Always use module.builtinModules for stable, public access.
The module.builtinModules array includes all built-in Node.js modules like ‘fs’, ‘path’, ‘http’, ‘crypto’, etc. Use it to validate module names or build autocomplete features.