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/learn/userland-migrations/ecosystem.md
+2-4Lines changed: 2 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,14 +12,12 @@ Sometimes the ecosystem creates awesome tools or libraries for node.js, but a na
12
12
13
13
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).
14
14
15
-
To run this codemdod, you have to use this command:
15
+
To run this codemod, you have to use this command:
16
16
17
17
```bash
18
-
npx codemod@latest run correct-ts-specifiers
18
+
npx codemod run @nodejs/correct-ts-specifiers
19
19
```
20
20
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
-
23
21
## Feedback
24
22
25
23
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).
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.
12
12
13
13
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.
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
+
43
75
## `rmdir`
44
76
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.
46
78
47
79
so this codemod handle [DEP0147](https://nodejs.org/api/deprecations.html#DEP0147).
Copy file name to clipboardExpand all lines: apps/site/pages/en/learn/userland-migrations/v20-to-v22.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
---
2
-
title: Nodejs v20 to v22
2
+
title: Node.js v20 to v22
3
3
layout: learn
4
4
authors: AugustinMauroy
5
5
---
6
6
7
-
# Nodejs v20 to v22
7
+
# Node.js v20 to v22
8
8
9
9
This page provides a list of codemods to help you migrate your code from Node.js v20 to v22.
10
10
@@ -17,7 +17,7 @@ So in [node.js v22](https://nodejs.org/fr/blog/release/v22.0.0#other-notable-cha
17
17
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.
0 commit comments