-
-
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
Open
AugustinMauroy
wants to merge
19
commits into
main
Choose a base branch
from
content(`userland-migration`)
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
5d7b7d7
content(`userland-migration`): make up to date
AugustinMauroy d398f90
Update introduction.md
AugustinMauroy 154245b
update
AugustinMauroy 010996b
Update navigation.json
AugustinMauroy 99f368e
Update
AugustinMauroy 17bcae9
use correct casing
AugustinMauroy 81ee06b
update
AugustinMauroy 6d86268
update after meeting
AugustinMauroy a009faf
fix link
AugustinMauroy c7d66ab
feat(mdx): add alertBox
AugustinMauroy 464acd9
fix
AugustinMauroy 9310143
update
AugustinMauroy ddc4cdb
update + improve
AugustinMauroy 2832256
Merge branch 'main' into content(`userland-migration`)
AugustinMauroy 608dae0
make date up to date
AugustinMauroy 42af1f4
Delete next.mdx.use.mjs
AugustinMauroy 23e7e1d
apply sugession
AugustinMauroy 8b4b976
use sha for image
AugustinMauroy 885d7d9
use alertBox as info
AugustinMauroy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
date: '2025-10-13T12:00:00.000Z' | ||
category: migrations | ||
title: Node.js v12 to v14 | ||
layout: blog-post | ||
author: AugustinMauroy | ||
--- | ||
|
||
# Node.js v12 to v14 | ||
|
||
<AlertBox level="info" 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> | ||
|
||
This page provides a list of codemods to help you migrate your code from Node.js v12 to v14. | ||
|
||
## `util-print-to-console-log` | ||
|
||
This recipe transforms calls of various now-deprecated `node:util` log functions into the modern alternative, `console.log` and `console.error`: | ||
|
||
- [DEP0026](https://nodejs.org/api/deprecations.html#DEP0026): `util.print` → `console.log` | ||
- [DEP0027](https://nodejs.org/api/deprecations.html#DEP0027): `util.puts` → `console.log` | ||
- [DEP0028](https://nodejs.org/api/deprecations.html#DEP0028): `util.debug` → `console.error` | ||
- [DEP0029](https://nodejs.org/api/deprecations.html#DEP0029): `util.error` → `console.error` | ||
|
||
```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'); | ||
``` | ||
|
||
### Source Code | ||
|
||
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). | ||
|
||
### Registry Link | ||
|
||
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/util-print-to-console-log). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
--- | ||
date: '2025-10-13T12:00:00.000Z' | ||
category: migrations | ||
title: Node.js v14 to v16 | ||
layout: blog-post | ||
author: AugustinMauroy | ||
--- | ||
|
||
# Node.js v14 to v16 | ||
|
||
<AlertBox level="info" 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. | ||
</AlertBox> | ||
|
||
This page provides a list of codemods to help you migrate your code from Node.js v14 to v16. | ||
|
||
## `create-require-from-path` | ||
|
||
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. | ||
|
||
```bash | ||
npx codemod run @nodejs/create-require-from-path | ||
``` | ||
|
||
### Example: | ||
|
||
```js displayName="Before" | ||
import { createRequireFromPath } from 'node:module'; | ||
|
||
const requireFromPath = createRequireFromPath('/path/to/module'); | ||
const myModule = requireFromPath('./myModule.cjs'); | ||
``` | ||
|
||
```js displayName="After" | ||
import { createRequire } from 'node:module'; | ||
|
||
const require = createRequire('/path/to/module'); | ||
const myModule = require('./myModule.cjs'); | ||
``` | ||
|
||
### Source Code | ||
|
||
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). | ||
|
||
### Registry Link | ||
|
||
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/create-require-from-path). | ||
|
||
## `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). | ||
AugustinMauroy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```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 | ||
} | ||
``` | ||
|
||
### Source Code | ||
|
||
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). | ||
|
||
### Registry Link | ||
|
||
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/process-main-module). | ||
|
||
## `process-mainModule-to-require-main` | ||
|
||
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. | ||
|
||
```bash | ||
npx codemod run @nodejs/process-mainModule-to-require-main | ||
``` | ||
|
||
### Example: | ||
|
||
```js displayName="Before" | ||
if (process.mainModule) { | ||
console.log('This script is the main module'); | ||
} | ||
``` | ||
|
||
```js displayName="After" | ||
if (require.main === module) { | ||
console.log('This script is the main module'); | ||
} | ||
``` | ||
|
||
## `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 }); | ||
``` | ||
|
||
### Source Code | ||
|
||
The source code for this codemod can be found in the [rmdir directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/rmdir). | ||
|
||
### Registry Link | ||
|
||
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/rmdir). | ||
|
||
## `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(); | ||
``` | ||
|
||
### Source Code | ||
|
||
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). | ||
|
||
### Registry Link | ||
|
||
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/tmpDir-to-tmpdir). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
date: '2025-10-13T12:00:00.000Z' | ||
category: migrations | ||
title: Node.js v20 to v22 | ||
layout: blog-post | ||
author: AugustinMauroy | ||
--- | ||
|
||
# Node.js v20 to v22 | ||
|
||
<AlertBox level="info" 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 replaced with an `with` attribute on the `import` statement. | ||
|
||
So in [node.js v22](https://nodejs.org/fr/blog/release/v22.0.0#other-notable-changes), the `import assert` feature was removed and the `with` attribute is required 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' }; | ||
``` | ||
|
||
### Source Code | ||
|
||
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). | ||
|
||
### Registry Link | ||
|
||
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/import-assertions-to-attributes). |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.