You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/site/pages/en/blog/migrations/v22-to-v24.mdx
+98-73Lines changed: 98 additions & 73 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,86 +69,132 @@ Node.js' `configure` script will warn if you attempt to build Node.js with a com
69
69
70
70
Some breaking changes or End of Life (EOL) deprecations in Node.js 23 and 24 have associated codemods to help you update your codebase. Below is a list of the available codemods for this migration:
71
71
72
-
### `fs-access-mode-constants`
73
-
74
-
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.
72
+
### `crypto-rsa-pss-update`
75
73
76
-
This codemod handles [DEP0176](https://nodejs.org/api/deprecations.html#DEP0176).
74
+
In [DEP0154](https://nodejs.org/docs/latest/api/deprecations.html#DEP0154), the `generateKeyPair` and `generateKeyPairSync` methods in the `crypto` module deprecated the `hash`, `mgf1Hash`, and `saltLength` options for the `'rsa-pss'` key type in favor of `hashAlgorithm`, `mgf1HashAlgorithm`, and `saltLength` respectively.
77
75
78
-
The source code for this codemod can be found in the [fs-access-mode-constants directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/fs-access-mode-constants).
76
+
The source code for this codemod can be found in the [crypto-rsa-pss-update directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/crypto-rsa-pss-update).
79
77
80
-
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/fs-access-mode-constants).
78
+
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/crypto-rsa-pss-update).
This codemod transforms the usage of `dirent.path` to use `dirent.parentPath`.
103
123
104
-
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.
124
+
See [DEP0178](https://nodejs.org/api/deprecations.html#DEP0178).
105
125
106
-
So this codemod handle [DEP0059](https://nodejs.org/api/deprecations.html#DEP0059).
126
+
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/dirent-path-to-parent-path).
107
127
108
128
```bash
109
-
npx codemod run @nodejs/util-log-to-console-log
129
+
npx codemod run @nodejs/dirent-path-to-parent-path
console.log(`Found ${dirent.name} in ${dirent.parentPath}`);
167
+
}
122
168
```
123
169
124
-
### `zlib-bytesRead-to-bytesWritten`
170
+
### `fs-access-mode-constants`
125
171
126
-
The [`zlib.bytesRead`](https://nodejs.org/api/zlib.html#zlib_bytesread) property was deprecated ([DEP0108](https://nodejs.org/api/deprecations.html#DEP0108)) in favor of [`zlib.bytesWritten`](https://nodejs.org/api/zlib.html#zlib_byteswritten). This codemod replaces `zlib.bytesRead` with `zlib.bytesWritten` for consistent stream property naming. It handles both CommonJS and ESM imports.
172
+
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.
127
173
128
-
The source code for this codemod can be found in the [zlib-bytesRead-to-bytesWritten directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/zlib-bytesread-to-byteswritten).
174
+
This codemod handles [DEP0176](https://nodejs.org/api/deprecations.html#DEP0176).
129
175
130
-
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/zlib-bytesread-to-byteswritten).
176
+
The source code for this codemod can be found in the [fs-access-mode-constants directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/fs-access-mode-constants).
177
+
178
+
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/fs-access-mode-constants).
131
179
132
180
```bash
133
-
npx codemod run @nodejs/zlib-bytesread-to-byteswritten
In [DEP0154](https://nodejs.org/docs/latest/api/deprecations.html#DEP0154), the `generateKeyPair` and `generateKeyPairSync` methods in the `crypto` module deprecated the `hash`, `mgf1Hash`, and `saltLength` options for the `'rsa-pss'` key type in favor of `hashAlgorithm`, `mgf1HashAlgorithm`, and `saltLength` respectively.
240
+
This recipe transforms the usage of `process.assert` to use `node:assert` module.
195
241
196
-
The source code for this codemod can be found in the [crypto-rsa-pss-update directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/crypto-rsa-pss-update).
242
+
See [DEP0100](https://nodejs.org/api/deprecations.html#DEP0100).
197
243
198
-
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/crypto-rsa-pss-update).
244
+
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/process-assert-to-node-assert).
199
245
200
246
```bash
201
-
npx codemod run @nodejs/crypto-rsa-pss-update
247
+
npx codemod run @nodejs/process-assert-to-node-assert
202
248
```
203
249
204
-
#### Example:
250
+
#### Example
205
251
206
252
```js displayName="Before"
207
-
constcrypto=require('node:crypto');
208
-
209
-
crypto.generateKeyPair(
210
-
'rsa-pss',
211
-
{
212
-
modulusLength:2048,
213
-
hash:'sha256',
214
-
mgf1Hash:'sha1',
215
-
saltLength:32,
216
-
},
217
-
(err, publicKey, privateKey) => {
218
-
// callback
219
-
}
220
-
);
253
+
process.assert(condition, 'Assertion failed');
221
254
```
222
255
223
256
```js displayName="After"
224
-
constcrypto=require('node:crypto');
225
-
226
-
crypto.generateKeyPair(
227
-
'rsa-pss',
228
-
{
229
-
modulusLength:2048,
230
-
hashAlgorithm:'sha256',
231
-
mgf1HashAlgorithm:'sha1',
232
-
saltLength:32,
233
-
},
234
-
(err, publicKey, privateKey) => {
235
-
// callback
236
-
}
237
-
);
257
+
importassertfrom'node:assert';
258
+
assert(condition, 'Assertion failed');
238
259
```
260
+
261
+
#### Additional Notes
262
+
263
+
This codemod use [`fs` capability](https://docs.codemod.com/jssg/security) to read the `package.json` file and determine if the project is using ES modules or CommonJS. Based on this information, it adds the appropriate import statement for the `assert` module.
0 commit comments