Skip to content

Commit c938bbb

Browse files
update
1 parent 79e1961 commit c938bbb

File tree

4 files changed

+71
-13
lines changed

4 files changed

+71
-13
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@ Sometimes the ecosystem creates awesome tools or libraries for node.js, but a na
1212

1313
When you want to [run typescript natively in Node.js](/learn/typescript/run-natively), you need to have a correct "specifiers" in your [imports statements](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import).
1414

15-
To run this codemdod, you have to use this command:
15+
To run this codemod, you have to use this command:
1616

1717
```bash
18-
npx codemod@latest run correct-ts-specifiers
18+
npx codemod run @nodejs/correct-ts-specifiers
1919
```
2020

21-
> **Note:** This codemod use "legacy" codemod CLI, if you wan to undersant more about it, you can read the [new codemod CLI announcement](https://codemod.com/blog/new-codemod-cli).
22-
2321
## Feedback
2422

2523
If you have any tools that you would like to be handle by userland-migrations, please open an issue on the [Node.js Userland Migrations repository](https://github.com/nodejs/userland-migrations/issues).

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ authors: JakobJingleheimer, AugustinMauroy
88

99
# Userland Migrations
1010

11-
Node.js provides migrations for "userland" (what you write vs node's own) source-code to facilitate adoption of new features and upgrading source-code affected by breaking changes. These are done in collaboration with [`codemod`](https://docs.codemod.com/introduction), who also work with other major projects like Next.js, React, and Tailwind. Node.js's migrations live in the [`nodejs/userland-migrations`](https://github.com/nodejs/userland-migrations) repository and are overseen by the `@nodejs/userland-migrations` team.
11+
Node.js offers migrations for "userland" code (anything outside the node executable) to help adopt new features and handle breaking changes. These are built in collaboration with Codemod, a platform focused on making it easy to build, share, and run codemods.
1212

1313
Official migrations are published under the `@nodejs` scope within the [codemod registry](https://codemod.link/nodejs-official). These have been reviewed and/or authored by Node.js members.
1414

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

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
title: Nodejs v14 to v16
2+
title: Node.js v14 to v16
33
layout: learn
44
authors: AugustinMauroy
55
---
66

7-
# Nodejs v14 to v16
7+
# Node.js v14 to v16
88

99
This page provides a list of codemods to help you migrate your code from Node.js v14 to v16.
1010

@@ -15,7 +15,7 @@ In Node.js v16, the `createRequire` function was introduced to allow you to crea
1515
So this codemod handle [DEP0130](https://nodejs.org/api/deprecations.html#DEP0130).
1616

1717
```bash
18-
npx codemod@latest @nodejs/create-require-from-path
18+
npx codemod run @nodejs/create-require-from-path
1919
```
2020

2121
Example:
@@ -40,14 +40,46 @@ const require = createRequire('/path/to/module');
4040
const myModule = require('./myModule.cjs');
4141
```
4242

43+
## `process-main-module`
44+
45+
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.
46+
47+
So the codemod handle [DEP0138](https://nodejs.org/api/deprecations.html#DEP0138).
48+
49+
```bash
50+
npx codemod run @nodejs/process-main-module
51+
```
52+
53+
Example:
54+
55+
**Before:**
56+
57+
```js
58+
if (process.mainModule === 'mod.js') {
59+
// cli thing
60+
} else {
61+
// module thing
62+
}
63+
```
64+
65+
**After:**
66+
67+
```js
68+
if (require.main === 'mod.js') {
69+
// cli thing
70+
} else {
71+
// module thing
72+
}
73+
```
74+
4375
## `rmdir`
4476

45-
In Node.js v16, the `fs.rmdir` function was deprecated in favor of `fs.rm` with the `{ recursive: true }` option. This codemod will help you replace the old `fs.rmdir` function with the new `fs.rm` function.
77+
The `fs.rmdir` function was deprecated in favor of `fs.rm` with the `{ recursive: true }` option. This codemod will help you replace the old `fs.rmdir` function with the new `fs.rm` function.
4678

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

4981
```bash
50-
npx codemod@latest @nodejs/rmdir
82+
npx codemod run @nodejs/rmdir
5183
```
5284

5385
Example:
@@ -77,3 +109,31 @@ fs.rmSync(path, { recursive: true, force: true });
77109
// Using fs.promises.rm with recursive and force options
78110
fs.promises.rm(path, { recursive: true, force: true });
79111
```
112+
113+
## `tmpDir-to-tmpdir`
114+
115+
The `tmpDir` function was renamed to `tmpdir` in Node.js v16. This codemod will help you replace all instances of `tmpDir` with `tmpdir`.
116+
117+
So the codemod handles [DEP0022](https://nodejs.org/docs/latest/api/deprecations.html#dep0022-ostmpdir).
118+
119+
```bash
120+
npx codemod run @nodejs/tmpDir-to-tmpdir
121+
```
122+
123+
Example:
124+
125+
**Before:**
126+
127+
```js
128+
import { tmpDir } from 'node:os';
129+
130+
const foo = tmpDir();
131+
```
132+
133+
**After:**
134+
135+
```js
136+
import { tmpdir } from 'node:os';
137+
138+
const foo = tmpdir();
139+
```

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
title: Nodejs v20 to v22
2+
title: Node.js v20 to v22
33
layout: learn
44
authors: AugustinMauroy
55
---
66

7-
# Nodejs v20 to v22
7+
# Node.js v20 to v22
88

99
This page provides a list of codemods to help you migrate your code from Node.js v20 to v22.
1010

@@ -17,7 +17,7 @@ So in [node.js v22](https://nodejs.org/fr/blog/release/v22.0.0#other-notable-cha
1717
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.
1818

1919
```bash
20-
npx codemod@latest @nodejs/import-assertions-to-attributes
20+
npx codemod run @nodejs/import-assertions-to-attributes
2121
```
2222

2323
Example:

0 commit comments

Comments
 (0)