-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
content(userland-migration
): make up to date
#8053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5d7b7d7
d398f90
154245b
010996b
99f368e
17bcae9
81ee06b
6d86268
a009faf
c7d66ab
464acd9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
|
||
import BadgeGroup from '@node-core/ui-components/Common/BadgeGroup'; | ||
|
||
import Button from './components/Common/Button'; | ||
import LinkWithArrow from './components/Common/LinkWithArrow'; | ||
import EOLAlertBox from './components/EOL/EOLAlert'; | ||
import EOLReleaseTable from './components/EOL/EOLReleaseTable'; | ||
import Link from './components/Link'; | ||
import UpcomingMeetings from './components/MDX/Calendar/UpcomingMeetings'; | ||
import PreviousReleasesTable from './components/Releases/PreviousReleasesTable'; | ||
import WithBadgeGroup from './components/withBadgeGroup'; | ||
import WithBanner from './components/withBanner'; | ||
import WithNodeRelease from './components/withNodeRelease'; | ||
|
||
/** | ||
* A full list of React Components that we want to pass through to MDX | ||
* | ||
* @satisfies {import('mdx/types').MDXComponents} | ||
*/ | ||
export const mdxComponents = { | ||
PreviousReleasesTable, | ||
// HOC for getting Node.js Release Metadata | ||
WithNodeRelease, | ||
// HOC for providing Banner Data | ||
WithBanner, | ||
// HOC for providing Badge Data | ||
WithBadgeGroup, | ||
// Standalone Badge Group | ||
BadgeGroup, | ||
// Renders an container for Upcoming Node.js Meetings | ||
UpcomingMeetings, | ||
// Renders an EOL alert | ||
EOLAlertBox, | ||
// Renders the EOL Table | ||
EOLReleaseTable, | ||
// Renders a Button Component for `button` tags | ||
Button, | ||
// Regular links (without arrow) | ||
Link, | ||
// Links with External Arrow | ||
LinkWithArrow, | ||
}; |
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,45 @@ | ||||||||||||||||
--- | ||||||||||||||||
date: '2025-09-26T12:00:00.000Z' | ||||||||||||||||
category: migrations | ||||||||||||||||
title: Node.js v12 to v14 | ||||||||||||||||
layout: blog-post | ||||||||||||||||
author: AugustinMauroy | ||||||||||||||||
--- | ||||||||||||||||
|
||||||||||||||||
# Node.js v12 to v14 | ||||||||||||||||
|
||||||||||||||||
<AlertBox level="warning" title="!"> | ||||||||||||||||
This article cover a part of the migration from Node.js v12 to v14. The | ||||||||||||||||
userland migrations team is working on more codemods to help you with the | ||||||||||||||||
migration. | ||||||||||||||||
</AlertBox> | ||||||||||||||||
Comment on lines
+11
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this really have to be an alert box? |
||||||||||||||||
|
||||||||||||||||
This page provides a list of codemods to help you migrate your code from Node.js v12 to v14. | ||||||||||||||||
|
||||||||||||||||
## `util-print-to-console-log` | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's link the package in the title |
||||||||||||||||
|
||||||||||||||||
This recipe transforms the usage of log functions from util, `print`, `puts`, `debug`, `error` to use `console.log()` or `console.error()`. | ||||||||||||||||
|
||||||||||||||||
So this codemod handle [DEP0026](https://nodejs.org/api/deprecations.html#DEP0026), [DEP0027](https://nodejs.org/api/deprecations.html#DEP0027), [DEP0028](https://nodejs.org/api/deprecations.html#DEP0028) and [DEP0029](https://nodejs.org/api/deprecations.html#DEP0029). | ||||||||||||||||
Comment on lines
+21
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
|
||||||||||||||||
```bash | ||||||||||||||||
npx codemod run @nodejs/create-require-from-path | ||||||||||||||||
``` | ||||||||||||||||
|
||||||||||||||||
### Example: | ||||||||||||||||
|
||||||||||||||||
```js displayName="Before" | ||||||||||||||||
const util = require('node:util'); | ||||||||||||||||
|
||||||||||||||||
util.print('Hello world'); | ||||||||||||||||
util.puts('Hello world'); | ||||||||||||||||
util.debug('Hello world'); | ||||||||||||||||
util.error('Hello world'); | ||||||||||||||||
``` | ||||||||||||||||
|
||||||||||||||||
```js displayName="After" | ||||||||||||||||
console.log('Hello world'); | ||||||||||||||||
console.log('Hello world'); | ||||||||||||||||
console.error('Hello world'); | ||||||||||||||||
console.error('Hello world'); | ||||||||||||||||
``` |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,130 @@ | ||||||||||
--- | ||||||||||
date: '2025-09-26T12:00:00.000Z' | ||||||||||
category: migrations | ||||||||||
title: Node.js v14 to v16 | ||||||||||
layout: blog-post | ||||||||||
author: AugustinMauroy | ||||||||||
--- | ||||||||||
|
||||||||||
# Node.js v14 to v16 | ||||||||||
|
||||||||||
<AlertBox | ||||||||||
level="warning" | ||||||||||
title="This article cover a part of the migration from Node.js v14 to v16. The userland migrations team is working on more codemods to help you with the migration." | ||||||||||
/> | ||||||||||
|
||||||||||
This page provides a list of codemods to help you migrate your code from Node.js v14 to v16. | ||||||||||
|
||||||||||
## `create-require-from-path` | ||||||||||
|
||||||||||
In Node.js v16, the `createRequire` function was introduced to allow you to create a `require` function that can be used in ESM modules. This codemod will help you replace the old `createRequireFromPath` function with the new `createRequire` function. | ||||||||||
|
||||||||||
So this codemod handle [DEP0130](https://nodejs.org/api/deprecations.html#DEP0130). | ||||||||||
Comment on lines
+20
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
```bash | ||||||||||
npx codemod run @nodejs/create-require-from-path | ||||||||||
``` | ||||||||||
|
||||||||||
### Example: | ||||||||||
|
||||||||||
```js displayName="Before" | ||||||||||
import { createRequireFromPath } from 'node:module'; | ||||||||||
|
||||||||||
// Using createRequireFromPath | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this comment needed, or is it implied? |
||||||||||
const requireFromPath = createRequireFromPath('/path/to/module'); | ||||||||||
const myModule = requireFromPath('./myModule.cjs'); | ||||||||||
``` | ||||||||||
|
||||||||||
```js displayName="After" | ||||||||||
import { createRequire } from 'node:module'; | ||||||||||
|
||||||||||
// Using createRequire with a specific path | ||||||||||
const require = createRequire('/path/to/module'); | ||||||||||
const myModule = require('./myModule.cjs'); | ||||||||||
``` | ||||||||||
|
||||||||||
## `process-main-module` | ||||||||||
|
||||||||||
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. | ||||||||||
|
||||||||||
So the codemod handle [DEP0138](https://nodejs.org/api/deprecations.html#DEP0138). | ||||||||||
Comment on lines
+48
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
```bash | ||||||||||
npx codemod run @nodejs/process-main-module | ||||||||||
``` | ||||||||||
|
||||||||||
### Example: | ||||||||||
|
||||||||||
```js displayName="Before" | ||||||||||
if (process.mainModule === 'mod.js') { | ||||||||||
// cli thing | ||||||||||
} else { | ||||||||||
// module thing | ||||||||||
} | ||||||||||
``` | ||||||||||
|
||||||||||
```js displayName="After" | ||||||||||
if (require.main === 'mod.js') { | ||||||||||
// cli thing | ||||||||||
} else { | ||||||||||
// module thing | ||||||||||
} | ||||||||||
``` | ||||||||||
|
||||||||||
## `rmdir` | ||||||||||
|
||||||||||
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. | ||||||||||
|
||||||||||
so this codemod handle [DEP0147](https://nodejs.org/api/deprecations.html#DEP0147). | ||||||||||
|
||||||||||
```bash | ||||||||||
npx codemod run @nodejs/rmdir | ||||||||||
``` | ||||||||||
|
||||||||||
### Example: | ||||||||||
|
||||||||||
```js displayName="Before" | ||||||||||
// Using fs.rmdir with the recursive option | ||||||||||
fs.rmdir(path, { recursive: true }, callback); | ||||||||||
|
||||||||||
// Using fs.rmdirSync with the recursive option | ||||||||||
fs.rmdirSync(path, { recursive: true }); | ||||||||||
|
||||||||||
// Using fs.promises.rmdir with the recursive option | ||||||||||
fs.promises.rmdir(path, { recursive: true }); | ||||||||||
``` | ||||||||||
|
||||||||||
```js displayName="After" | ||||||||||
// Using fs.rm with recursive and force options | ||||||||||
fs.rm(path, { recursive: true, force: true }, callback); | ||||||||||
|
||||||||||
// Using fs.rmSync with recursive and force options | ||||||||||
fs.rmSync(path, { recursive: true, force: true }); | ||||||||||
|
||||||||||
// Using fs.promises.rm with recursive and force options | ||||||||||
fs.promises.rm(path, { recursive: true, force: true }); | ||||||||||
``` | ||||||||||
|
||||||||||
## `tmpDir-to-tmpdir` | ||||||||||
|
||||||||||
The `tmpDir` function was renamed to `tmpdir` in Node.js v16. This codemod will help you replace all instances of `tmpDir` with `tmpdir`. | ||||||||||
|
||||||||||
So the codemod handles [DEP0022](https://nodejs.org/docs/latest/api/deprecations.html#dep0022-ostmpdir). | ||||||||||
|
||||||||||
```bash | ||||||||||
npx codemod run @nodejs/tmpDir-to-tmpdir | ||||||||||
``` | ||||||||||
|
||||||||||
### Example: | ||||||||||
|
||||||||||
```js displayName="Before" | ||||||||||
import { tmpDir } from 'node:os'; | ||||||||||
|
||||||||||
const foo = tmpDir(); | ||||||||||
``` | ||||||||||
|
||||||||||
```js displayName="After" | ||||||||||
import { tmpdir } from 'node:os'; | ||||||||||
|
||||||||||
const foo = tmpdir(); | ||||||||||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
date: '2025-09-26T12:00:00.000Z' | ||
category: migrations | ||
title: Node.js v20 to v22 | ||
layout: blog-post | ||
author: AugustinMauroy | ||
--- | ||
|
||
# Node.js v20 to v22 | ||
|
||
<AlertBox level="warning" title="!"> | ||
This article cover a part of the migration from Node.js v20 to v22. The | ||
userland migrations team is working on more codemods to help you with the | ||
migration. | ||
</AlertBox> | ||
|
||
This page provides a list of codemods to help you migrate your code from Node.js v20 to v22. | ||
|
||
## `import-assertions-to-attributes` | ||
|
||
During the process of TC39 standardization, the `import assert` feature was introduced to allow importing [JSON modules](https://tc39.es/proposal-json-modules/) but during the during the transition to stage 4, the `assert` keyword was removed and replaced with an `with` attribute on the `import` statement. | ||
AugustinMauroy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
So in [node.js v22](https://nodejs.org/fr/blog/release/v22.0.0#other-notable-changes), the `import assert` feature was removed and you need to use the `with` attribute instead. | ||
|
||
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. | ||
AugustinMauroy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```bash | ||
npx codemod run @nodejs/import-assertions-to-attributes | ||
``` | ||
|
||
### Example: | ||
|
||
```js displayName="Before" | ||
import jsonData from './data.json' assert { type: 'json' }; | ||
``` | ||
|
||
```js displayName="After" | ||
import jsonData from './data.json' with { type: 'json' }; | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's wait for v24 to officially get it's LTS badge |
||
date: '2025-09-26T12:00:00.000Z' | ||
category: migrations | ||
title: Node.js v22 to v24 | ||
layout: blog-post | ||
author: AugustinMauroy | ||
--- | ||
|
||
# Node.js v22 to v24 | ||
|
||
<AlertBox level="warning" title="!"> | ||
This article cover a part of the migration from Node.js v22 to v24. The | ||
userland migrations team is working on more codemods to help you with the | ||
migration. | ||
</AlertBox> | ||
|
||
This page provides a list of codemods to help you migrate your code from Node.js v22 to v24. | ||
|
||
## `fs-access-mode-constants` | ||
|
||
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. | ||
|
||
So this codemod handle [DEP0176](https://nodejs.org/api/deprecations.html#DEP0176). | ||
|
||
```js displayName="Before" | ||
const fs = require('node:fs'); | ||
|
||
fs.access('/path/to/file', fs.F_OK, callback); | ||
fs.access('/path/to/file', fs.R_OK | fs.W_OK, callback); | ||
``` | ||
|
||
```js displayName="After" | ||
const fs = require('node:fs'); | ||
|
||
fs.access('/path/to/file', fs.constants.F_OK, callback); | ||
fs.access('/path/to/file', fs.constants.R_OK | fs.constants.W_OK, callback); | ||
``` | ||
|
||
## `util-log-to-console-log` | ||
|
||
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 | ||
|
||
So this codemod handle [DEP0059](https://nodejs.org/api/deprecations.html#DEP0059). | ||
|
||
### Example: | ||
|
||
```js displayName="Before" | ||
const util = require('node:util'); | ||
|
||
util.log('Hello world'); | ||
``` | ||
|
||
```js displayName="After" | ||
console.log(new Date().toLocaleString(), 'Hello world'); | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.