-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Content(migrations): update #8881
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
6
commits into
main
Choose a base branch
from
content-codemod-update
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 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8714fab
content(migrations): add more codemod
AugustinMauroy e8f33c1
fix: use diff
AugustinMauroy 34d5395
content: migrations/axios-to-fetch
AugustinMauroy 56267bd
lint:fix
AugustinMauroy a00d184
Update v14-to-v16.mdx
AugustinMauroy c32ea58
Update axios-to-fetch.mdx
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
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,51 @@ | ||
| --- | ||
| date: '2025-10-28T00:02:00.000Z' | ||
| category: migrations | ||
| title: Node.js v16 to v18 | ||
| layout: blog-post | ||
| author: AugustinMauroy | ||
| --- | ||
|
|
||
| # Node.js v16 to v18 | ||
|
|
||
| <AlertBox level="info" title="!"> | ||
| This article covers a part of the migration from Node.js v16 to v18. 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 v16 to v18. | ||
|
|
||
| ## `err-invalid-callback` | ||
|
|
||
| In Node.js v18, the [DEP0159](https://nodejs.org/api/deprecations.html#DEP0159) deprecation was introduced, which deprecated the `ERR_INVALID_CALLBACK` error code in favor of `ERR_INVALID_ARG_TYPE`. This codemod will help you replace any references to the old error code with the new one. | ||
|
|
||
| The source code for this codemod can be found in the [err-invalid-callback directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/err-invalid-callback). | ||
|
|
||
| You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/err-invalid-callback). | ||
|
|
||
| ```bash | ||
| npx codemod run @nodejs/err-invalid-callback | ||
| ``` | ||
|
|
||
| ### Example: | ||
|
|
||
| ```diff | ||
| try { | ||
| fs.readFile("file.txt", "invalid-callback"); | ||
| } catch (err) { | ||
| - if (err.code === "ERR_INVALID_CALLBACK") { | ||
| + if (err.code === "ERR_INVALID_ARG_TYPE") { | ||
| console.error("Invalid callback provided"); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Also handles deduplication when both codes were already checked: | ||
|
|
||
| ```diff | ||
| const isCallbackError = | ||
| - err.code === "ERR_INVALID_CALLBACK" || | ||
| - err.code === "ERR_INVALID_ARG_TYPE"; | ||
| + err.code === "ERR_INVALID_ARG_TYPE"; | ||
| ``` |
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
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.