Skip to content

Commit 5a6d2f6

Browse files
Update
1 parent cc5b642 commit 5a6d2f6

File tree

6 files changed

+71
-33
lines changed

6 files changed

+71
-33
lines changed

apps/site/navigation.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,10 @@
418418
"link": "/learn/userland-migrations/ecosystem",
419419
"label": "components.navigation.learn.userland-migrations.links.ecosystem"
420420
},
421+
"v22-to-v24": {
422+
"link": "/learn/userland-migrations/v22-to-v24",
423+
"label": "components.navigation.learn.userland-migrations.links.v22-to-v24"
424+
},
421425
"v20-to-v22": {
422426
"link": "/learn/userland-migrations/v20-to-v22",
423427
"label": "components.navigation.learn.userland-migrations.links.v20-to-v22"

apps/site/pages/en/learn/userland-migrations/introduction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ The Node.js Userland Migrations team seeks to help developers migrate their code
2121
To use a codemod, you can run the following command in your terminal:
2222

2323
```bash
24-
npx codemod@next <codemod-name>
24+
npx codemod <codemod-name>
2525
```
2626

2727
Replace `<codemod-name>` with the name of the codemod you want to run. For example, if you want to run the `@nodejs/import-assertions-to-attributes` codemod on your project, you would run:
2828

2929
```bash
30-
npx codemod@next @nodejs/import-assertions-to-attributes
30+
npx codemod @nodejs/import-assertions-to-attributes
3131
```
3232

3333
## Good Practices

apps/site/pages/en/learn/userland-migrations/v14-to-v16.md

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,17 @@ So this codemod handle [DEP0130](https://nodejs.org/api/deprecations.html#DEP013
1818
npx codemod run @nodejs/create-require-from-path
1919
```
2020

21-
Example:
21+
### Example:
2222

23-
**Before:**
24-
25-
```js
23+
```js displayName="Before"
2624
import { createRequireFromPath } from 'node:module';
2725

2826
// Using createRequireFromPath
2927
const requireFromPath = createRequireFromPath('/path/to/module');
3028
const myModule = requireFromPath('./myModule.cjs');
3129
```
3230

33-
**After:**
34-
35-
```js
31+
```js displayName="After"
3632
import { createRequire } from 'node:module';
3733

3834
// Using createRequire with a specific path
@@ -50,21 +46,17 @@ So the codemod handle [DEP0138](https://nodejs.org/api/deprecations.html#DEP0138
5046
npx codemod run @nodejs/process-main-module
5147
```
5248

53-
Example:
49+
### Example:
5450

55-
**Before:**
56-
57-
```js
51+
```js displayName="Before"
5852
if (process.mainModule === 'mod.js') {
5953
// cli thing
6054
} else {
6155
// module thing
6256
}
6357
```
6458

65-
**After:**
66-
67-
```js
59+
```js displayName="After"
6860
if (require.main === 'mod.js') {
6961
// cli thing
7062
} else {
@@ -82,11 +74,9 @@ so this codemod handle [DEP0147](https://nodejs.org/api/deprecations.html#DEP014
8274
npx codemod run @nodejs/rmdir
8375
```
8476

85-
Example:
77+
### Example:
8678

87-
**Before:**
88-
89-
```js
79+
```js displayName="Before"
9080
// Using fs.rmdir with the recursive option
9181
fs.rmdir(path, { recursive: true }, callback);
9282

@@ -97,9 +87,7 @@ fs.rmdirSync(path, { recursive: true });
9787
fs.promises.rmdir(path, { recursive: true });
9888
```
9989

100-
**After:**
101-
102-
```js
90+
```js displayName="After"
10391
// Using fs.rm with recursive and force options
10492
fs.rm(path, { recursive: true, force: true }, callback);
10593

@@ -120,19 +108,15 @@ So the codemod handles [DEP0022](https://nodejs.org/docs/latest/api/deprecations
120108
npx codemod run @nodejs/tmpDir-to-tmpdir
121109
```
122110

123-
Example:
111+
### Example:
124112

125-
**Before:**
126-
127-
```js
113+
```js displayName="Before"
128114
import { tmpDir } from 'node:os';
129115

130116
const foo = tmpDir();
131117
```
132118

133-
**After:**
134-
135-
```js
119+
```js displayName="After"
136120
import { tmpdir } from 'node:os';
137121

138122
const foo = tmpdir();

apps/site/pages/en/learn/userland-migrations/v20-to-v22.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ Also note that the `with` keyword as been introduce in [node.js v18.20](https://
2020
npx codemod run @nodejs/import-assertions-to-attributes
2121
```
2222

23-
Example:
23+
### Example:
2424

25-
```js
25+
```js displayName="Before"
2626
import jsonData from './data.json' assert { type: 'json' };
27-
// becomes
27+
```
28+
29+
```js displayName="After"
2830
import jsonData from './data.json' with { type: 'json' };
2931
```
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: Node.js v22 to v24
3+
layout: learn
4+
authors: AugustinMauroy
5+
---
6+
7+
# Node.js v22 to v24
8+
9+
This page provides a list of codemods to help you migrate your code from Node.js v22 to v24.
10+
11+
## `fs-access-mode-constants`
12+
13+
In Node.js 24, the `fs` module introduced a runtime deprecation for `F_OK`, `R_OK`, `W_OK`, and `X_OK` getters exposed directly on `node:fs`. Get them from `fs.constants` or `fs.promises.constants` instead.
14+
15+
So this codemod handle [DEP0176](https://nodejs.org/api/deprecations.html#DEP0176).
16+
17+
```js displayName="Before"
18+
const fs = require('node:fs');
19+
20+
fs.access('/path/to/file', fs.F_OK, callback);
21+
fs.access('/path/to/file', fs.R_OK | fs.W_OK, callback);
22+
```
23+
24+
```js displayName="After"
25+
const fs = require('node:fs');
26+
27+
fs.access('/path/to/file', fs.constants.F_OK, callback);
28+
fs.access('/path/to/file', fs.constants.R_OK | fs.constants.W_OK, callback);
29+
```
30+
31+
## `util-log-to-console-log`
32+
33+
In Node.js v23, the `util.log` function was deprecated in favor of using `console.log` directly. Because it's an unmaintained legacy API that was exposed to user land by accident
34+
35+
So this codemod handle [DEP0059](https://nodejs.org/api/deprecations.html#DEP0059).
36+
37+
### Example:
38+
39+
```js displayName="Before"
40+
const util = require('node:util');
41+
42+
util.log('Hello world');
43+
```
44+
45+
```js displayName="After"
46+
console.log(new Date().toLocaleString(), 'Hello world');
47+
```

packages/i18n/src/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"userland-migrations": "Userland Migrations",
105105
"introduction": "Introduction to Userland Migrations",
106106
"ecosystem": "Ecosystem to Node.js",
107+
"v22-to-v24": "Node.js v22 to v24",
107108
"v20-to-v22": "Node.js v20 to v22",
108109
"v14-to-v16": "Node.js v14 to v16"
109110
}

0 commit comments

Comments
 (0)