Skip to content

Commit fe3f9d5

Browse files
update
Co-Authored-By: Richard Lau <[email protected]>
1 parent 89ef3ba commit fe3f9d5

4 files changed

Lines changed: 117 additions & 66 deletions

File tree

apps/site/pages/en/blog/migrations/v12-to-v14.mdx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ This recipe transforms calls of various now-deprecated `node:util` log functions
2525
- [DEP0028](https://nodejs.org/api/deprecations.html#DEP0028): `util.debug``console.error`
2626
- [DEP0029](https://nodejs.org/api/deprecations.html#DEP0029): `util.error``console.error`
2727

28+
The source code for this codemod can be found in the [util-print-to-console-log directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/util-print-to-console-log).
29+
30+
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/util-print-to-console-log).
31+
2832
```bash
2933
npx codemod run @nodejs/create-require-from-path
3034
```
@@ -46,11 +50,3 @@ console.log('Hello world');
4650
console.error('Hello world');
4751
console.error('Hello world');
4852
```
49-
50-
### Source Code
51-
52-
The source code for this codemod can be found in the [util-print-to-console-log directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/util-print-to-console-log).
53-
54-
### Registry Link
55-
56-
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/util-print-to-console-log).

apps/site/pages/en/blog/migrations/v14-to-v16.mdx

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ This page provides a list of codemods to help you migrate your code from Node.js
2020

2121
Node.js v16 replaced the [`createRequireFromPath`](https://nodejs.org/api/module.html#module_module_createrequirefrompath) function, deprecated in [DEP0148](https://nodejs.org/api/deprecations.html#DEP0148), with the modern [`createRequire`](https://nodejs.org/api/module.html#module_module_createrequire) function. This codemod replaces calls of the deprecated function with the modern alternative mentioned.
2222

23+
The source code for this codemod can be found in the [create-require-from-path directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/create-require-from-path).
24+
25+
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/create-require-from-path).
26+
2327
```bash
2428
npx codemod run @nodejs/create-require-from-path
2529
```
@@ -40,20 +44,16 @@ const require = createRequire('/path/to/module');
4044
const myModule = require('./myModule.cjs');
4145
```
4246

43-
### Source Code
44-
45-
The source code for this codemod can be found in the [create-require-from-path directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/create-require-from-path).
46-
47-
### Registry Link
48-
49-
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/create-require-from-path).
50-
5147
## `process-main-module`
5248

5349
The `process.mainModule` property was deprecated in favor of `require.main`. This codemod will help you replace the old `process.mainModule` usage with the new `require.main` usage.
5450

5551
So the codemod handle [DEP0138](https://nodejs.org/api/deprecations.html#DEP0138).
5652

53+
The source code for this codemod can be found in the [process-main-module directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/process-main-module).
54+
55+
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/process-main-module).
56+
5757
```bash
5858
npx codemod run @nodejs/process-main-module
5959
```
@@ -76,18 +76,14 @@ if (require.main === 'mod.js') {
7676
}
7777
```
7878

79-
### Source Code
80-
81-
The source code for this codemod can be found in the [process-main-module directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/process-main-module).
82-
83-
### Registry Link
84-
85-
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/process-main-module).
86-
8779
## `process-mainModule-to-require-main`
8880

8981
The [`process.mainModule`](https://nodejs.org/api/process.html#process_process_mainmodule) property was deprecated ([DEP0144](https://nodejs.org/api/deprecations.html#DEP0144)) in favor of [`require.main`](https://nodejs.org/api/modules.html#modules_accessing_the_main_module). This codemod replaces calls of the deprecated property with the modern alternative mentioned.
9082

83+
The source code for this codemod can be found in the [process-mainModule-to-require-main directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/process-main-module).
84+
85+
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/process-mainModule-to-require-main).
86+
9187
```bash
9288
npx codemod run @nodejs/process-mainModule-to-require-main
9389
```
@@ -112,6 +108,10 @@ The `fs.rmdir` function was deprecated in favor of `fs.rm` with the `{ recursive
112108

113109
so this codemod handle [DEP0147](https://nodejs.org/api/deprecations.html#DEP0147).
114110

111+
The source code for this codemod can be found in the [rmdir directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/rmdir).
112+
113+
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/rmdir).
114+
115115
```bash
116116
npx codemod run @nodejs/rmdir
117117
```
@@ -140,20 +140,16 @@ fs.rmSync(path, { recursive: true, force: true });
140140
fs.promises.rm(path, { recursive: true, force: true });
141141
```
142142

143-
### Source Code
144-
145-
The source code for this codemod can be found in the [rmdir directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/rmdir).
146-
147-
### Registry Link
148-
149-
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/rmdir).
150-
151143
## `tmpDir-to-tmpdir`
152144

153145
The `tmpDir` function was renamed to `tmpdir` in Node.js v16. This codemod will help you replace all instances of `tmpDir` with `tmpdir`.
154146

155147
So the codemod handles [DEP0022](https://nodejs.org/docs/latest/api/deprecations.html#dep0022-ostmpdir).
156148

149+
The source code for this codemod can be found in the [tmpdir-to-tmpdir directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/tmpdir-to-tmpdir).
150+
151+
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/tmpDir-to-tmpdir).
152+
157153
```bash
158154
npx codemod run @nodejs/tmpDir-to-tmpdir
159155
```
@@ -171,11 +167,3 @@ import { tmpdir } from 'node:os';
171167

172168
const foo = tmpdir();
173169
```
174-
175-
### Source Code
176-
177-
The source code for this codemod can be found in the [tmpdir-to-tmpdir directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/tmpdir-to-tmpdir).
178-
179-
### Registry Link
180-
181-
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/tmpDir-to-tmpdir).

apps/site/pages/en/blog/migrations/v20-to-v22.mdx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ So in [node.js v22](https://nodejs.org/fr/blog/release/v22.0.0#other-notable-cha
2424

2525
Also note that the `with` keyword as been introduce in [node.js v18.20](https://nodejs.org/fr/blog/release/v18.20.0#added-support-for-import-attributes) but it was not mandatory until v22.
2626

27+
The source code for this codemod can be found in the [import-assertions-to-attributes directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/import-assertions-to-attributes).
28+
29+
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/import-assertions-to-attributes).
30+
2731
```bash
2832
npx codemod run @nodejs/import-assertions-to-attributes
2933
```
@@ -37,11 +41,3 @@ import jsonData from './data.json' assert { type: 'json' };
3741
```js displayName="After"
3842
import jsonData from './data.json' with { type: 'json' };
3943
```
40-
41-
### Source Code
42-
43-
The source code for this codemod can be found in the [import-assertions-to-attributes directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/import-assertions-to-attributes).
44-
45-
### Registry Link
46-
47-
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/import-assertions-to-attributes).

apps/site/pages/en/blog/migrations/v22-to-v24.mdx

Lines changed: 89 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,79 @@ author: AugustinMauroy
1212
This article cover a part of the migration from Node.js v22 to v24. The
1313
userland migrations team is working on more codemods to help you with the
1414
migration.
15+
16+
Missing codemods will be added over time. If you have specific needs.
17+
18+
<a href="https://github.com/nodejs/userland-migrations/issues/239">
19+
Read this issue to learn where we are in the process. And how to manually migrate your code.
20+
</a>
1521
</AlertBox>
1622

17-
This page provides a list of codemods to help you migrate your code from Node.js v22 to v24.
23+
With the release of [Node.js 24.11.0](https://nodejs.org/blog/release/v24.11.0), the Node.js 24 release line has entered Long-Term Support (LTS) and will continue to receive updates through to the end of April 2028.
24+
25+
If you are migrating from Node.js 22 LTS, the following summarizes the breaking changes that came in [Node.js 23.0.0](https://nodejs.org/blog/release/v23.0.0) and [Node.js 24.0.0](https://nodejs.org/blog/release/v24.0.0).
26+
27+
### Platform support
28+
29+
Node.js no longer provides [pre-built binaries](https://nodejs.org/en/download) for:
30+
31+
- 32-bit Windows (x86) as of Node.js 23.0.0.
32+
- 32-bit Linux on armv7 as of Node.js 24.0.0.
33+
34+
Pre-built binaries for macOS now require a minimum of macOS 13.5.
35+
36+
Pre-built binaries for Linux on arm64, ppc64le, s390x and x64 continue to be compatible with glibc 2.28 and above (no change from Node.js 22).
37+
38+
Please refer to [additional notes if you are building Node.js from source](#building-nodejs-from-source).
39+
40+
### Breaking changes
41+
42+
### OpenSSL 3.5
43+
44+
Pre-built binaries of Node.js 24 LTS, or builds using the default build configuration options, include OpenSSL 3.5. Node.js 24 LTS uses the default security level from OpenSSL 3.5 of `2`, which means that:
45+
46+
- RSA, DSA and DH keys shorter than 2048 bits and ECC keys shorter than 224 bits are prohibited.
47+
- Any cipher suite using RC4 is also prohibited.
1848

19-
## `fs-access-mode-constants`
49+
If you rely on older keys or weak ciphers, test your workloads against Node.js 24 builds (or adjust key/cipher choices) before upgrading.
50+
51+
### Other behavioral changes and argument validation
52+
53+
The release includes a number of behavior and validation changes (stricter `fetch()` compliance, AbortSignal validation, stream/pipe errors now throwing, changes to Buffer behavior, path handling fixes on Windows, test runner defaults, and more). See the full list below.
54+
55+
### C/C++ addons
56+
57+
Addons linking against V8 APIs may need updates for V8 13.6; C++20 support may be required where previously C++17 was used. Where possible, prefer NODE-API to reduce rebuild churn.
58+
59+
### Building Node.js from source
60+
61+
If you are building Node.js from source, you may need to update your compiler toolchain:
62+
63+
- For AIX and Linux platforms, the minimum supported version of [gcc](https://gcc.gnu.org/) is 12.2.
64+
- For macOS the minimum supported version of [Xcode](https://developer.apple.com/xcode/) is 16.1.
65+
66+
Node.js' `configure` script will warn if you attempt to build Node.js with a compiler toolchain that does not meet the minimum supported version but will not actively prevent you from trying.
67+
68+
## Available Codemods
69+
70+
Some breaking changes or End of Life 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+
72+
### `fs-access-mode-constants`
2073

2174
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.
2275

2376
This codemod handles [DEP0176](https://nodejs.org/api/deprecations.html#DEP0176).
2477

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).
79+
80+
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/fs-access-mode-constants).
81+
82+
```bash
83+
npx codemod run @nodejs/fs-access-mode-constants
84+
```
85+
86+
#### Example:
87+
2588
```js displayName="Before"
2689
const fs = require('node:fs');
2790

@@ -36,12 +99,16 @@ fs.access('/path/to/file', fs.constants.F_OK, callback);
3699
fs.access('/path/to/file', fs.constants.R_OK | fs.constants.W_OK, callback);
37100
```
38101

39-
## `util-log-to-console-log`
102+
### `util-log-to-console-log`
40103

41104
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
42105

43106
So this codemod handle [DEP0059](https://nodejs.org/api/deprecations.html#DEP0059).
44107

108+
```bash
109+
npx codemod run @nodejs/util-log-to-console-log
110+
```
111+
45112
### Example:
46113

47114
```js displayName="Before"
@@ -54,15 +121,19 @@ util.log('Hello world');
54121
console.log(new Date().toLocaleString(), 'Hello world');
55122
```
56123

57-
## `zlib-bytesRead-to-bytesWritten`
124+
### `zlib-bytesRead-to-bytesWritten`
58125

59126
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.
60127

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).
129+
130+
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/zlib-bytesread-to-byteswritten).
131+
61132
```bash
62-
npx codemod run @nodejs/zlib-bytesRead-to-bytesWritten
133+
npx codemod run @nodejs/zlib-bytesread-to-byteswritten
63134
```
64135

65-
### Example:
136+
#### Example:
66137

67138
```js displayName="Before"
68139
const zlib = require('node:zlib');
@@ -80,15 +151,19 @@ gzip.on('end', () => {
80151
});
81152
```
82153

83-
## `fs-truncate-to-ftruncate`
154+
### `fs-truncate-to-ftruncate`
84155

85156
The [`fs.truncate`](https://nodejs.org/api/fs.html#fs_fs_truncate_path_len_callback) function was deprecated ([DEP0081](https://nodejs.org/api/deprecations.html#DEP0081)) when used with a file descriptor. Use [`fs.ftruncate`](https://nodejs.org/api/fs.html#fs_fs_ftruncate_fd_len_callback) instead.
86157

158+
The source code for this codemod can be found in the [fs-truncate-fd-deprecation directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/fs-truncate-fd-deprecation).
159+
160+
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/fs-truncate-to-ftruncate).
161+
87162
```bash
88163
npx codemod run @nodejs/fs-truncate-to-ftruncate
89164
```
90165

91-
### Example:
166+
#### Example:
92167

93168
```js displayName="Before"
94169
const { truncate, open, close } = require('node:fs');
@@ -114,15 +189,19 @@ open('file.txt', 'w', (err, fd) => {
114189
});
115190
```
116191

117-
## `crypto-rsa-pss-update`
192+
### `crypto-rsa-pss-update`
118193

119194
Codemod to handle Node.js crypto deprecation [DEP0154](https://nodejs.org/docs/latest/api/deprecations.html#DEP0154) by transforming deprecated RSA-PSS key generation options.
120195

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).
197+
198+
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/crypto-rsa-pss-update).
199+
121200
```bash
122201
npx codemod run @nodejs/crypto-rsa-pss-update
123202
```
124203

125-
### Example:
204+
#### Example:
126205

127206
```js displayName="Before"
128207
const crypto = require('node:crypto');
@@ -157,11 +236,3 @@ crypto.generateKeyPair(
157236
}
158237
);
159238
```
160-
161-
### Source Code
162-
163-
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).
164-
165-
### Registry Link
166-
167-
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/crypto-rsa-pss-update).

0 commit comments

Comments
 (0)