|
1 |
| -# `fs.rmdir` DEP0147 |
| 1 | +# `repl.builtinModules` DEP0191 |
2 | 2 |
|
3 |
| -This recipe provides a guide for migrating from the deprecated `fs.rmdir` and its synchronous and promise-based counterparts to the new `fs.rm` method in Node.js. |
| 3 | +This recipe provides a guide for migrating from the deprecated `repl.builtinModules` to the new `module.builtinModules` property in Node.js. |
4 | 4 |
|
5 |
| -See [DEP0147](https://nodejs.org/api/deprecations.html#DEP0147). |
| 5 | +See [DEP0191](https://nodejs.org/api/deprecations.html#DEP0191). |
6 | 6 |
|
7 | 7 | ## Examples
|
8 | 8 |
|
9 | 9 | **Before:**
|
10 |
| - |
11 | 10 | ```js
|
12 |
| -// Using fs.rmdir with the recursive option |
13 |
| -fs.rmdir(path, { recursive: true }, callback); |
| 11 | +// Using require with namespace import |
| 12 | +const repl = require('node:repl'); |
| 13 | +console.log(repl.builtinModules); |
| 14 | + |
| 15 | +// Using require with destructuring |
| 16 | +const { builtinModules } = require('node:repl'); |
| 17 | + |
| 18 | +// Using require with mixed destructuring |
| 19 | +const { builtinModules, foo } = require('node:repl'); |
| 20 | + |
| 21 | +// Using ES6 import with named import |
| 22 | +import { builtinModules } from 'node:repl'; |
| 23 | + |
| 24 | +// Using ES6 import with mixed named imports |
| 25 | +import { builtinModules, foo } from 'node:repl'; |
14 | 26 |
|
15 |
| -// Using fs.rmdirSync with the recursive option |
16 |
| -fs.rmdirSync(path, { recursive: true }); |
| 27 | +// Using ES6 import with default import |
| 28 | +import repl from 'node:repl'; |
| 29 | +console.log(repl.builtinModules); |
17 | 30 |
|
18 |
| -// Using fs.promises.rmdir with the recursive option |
19 |
| -fs.promises.rmdir(path, { recursive: true }); |
| 31 | +// Using ES6 import with namespace import |
| 32 | +import * as repl from 'node:repl'; |
| 33 | +console.log(repl.builtinModules); |
20 | 34 | ```
|
21 | 35 |
|
22 | 36 | **After:**
|
23 |
| - |
24 | 37 | ```js
|
25 |
| -// Using fs.rm with recursive and force options |
26 |
| -fs.rm(path, { recursive: true, force: true }, callback); |
| 38 | +// Using require with namespace import |
| 39 | +const module = require('node:module'); |
| 40 | +console.log(module.builtinModules); |
| 41 | + |
| 42 | +// Using require with destructuring |
| 43 | +const { builtinModules } = require('node:module'); |
| 44 | + |
| 45 | +// Using require with mixed destructuring |
| 46 | +const { foo } = require('node:repl'); |
| 47 | +const { builtinModules } = require('node:module'); |
| 48 | + |
| 49 | +// Using ES6 import with named import |
| 50 | +import { builtinModules } from 'node:module'; |
| 51 | + |
| 52 | +// Using ES6 import with mixed named imports |
| 53 | +import { foo } from 'node:repl'; |
| 54 | +import { builtinModules } from 'node:module'; |
27 | 55 |
|
28 |
| -// Using fs.rmSync with recursive and force options |
29 |
| -fs.rmSync(path, { recursive: true, force: true }); |
| 56 | +// Using ES6 import with default import |
| 57 | +import module from 'node:module'; |
| 58 | +console.log(module.builtinModules); |
30 | 59 |
|
31 |
| -// Using fs.promises.rm with recursive and force options |
32 |
| -fs.promises.rm(path, { recursive: true, force: true }); |
| 60 | +// Using ES6 import with namespace import |
| 61 | +import * as module from 'node:module'; |
| 62 | +console.log(module.builtinModules); |
33 | 63 | ```
|
0 commit comments