Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion apps/site/pages/en/blog/migrations/v16-to-v18.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,33 @@ author: AugustinMauroy

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

## `dns-lookup-options-coercion`

In Node.js v18, the [DEP0153](https://nodejs.org/api/deprecations.html#dep0153-dnslookup-and-dnspromiseslookup-options-type-coercion) deprecation was granted to end-of-life, which means that the `dns.lookup()` and `dnsPromises.lookup()` functions will no longer coerce option values to their proper types. This codemod will help you convert any literal option values to their proper types.
Comment thread
Copilot marked this conversation as resolved.
Outdated

The source code for this codemod can be found in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/dns-lookup-options-coercion).
Comment thread
Copilot marked this conversation as resolved.
Outdated

```bash
npx codemod run @nodejs/dns-lookup-options-coercion
```

### Examples:

```diff
const dns = require("node:dns");

- dns.lookup("example.com", { family: "4", all: 1 }, callback);
+ dns.lookup("example.com", { family: 4, all: true }, callback);
```

```diff
import { lookup } from "node:dns/promises";

- await lookup("example.com", { family: "6", verbatim: 0 });
+ await lookup("example.com", { family: 6, verbatim: false });
```


## `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.
Expand All @@ -28,7 +55,7 @@ You can find this codemod in the [Codemod Registry](https://app.codemod.com/regi
npx codemod run @nodejs/err-invalid-callback
```

### Example:
### Examples:

```diff
try {
Expand Down
10 changes: 10 additions & 0 deletions apps/site/pages/en/blog/migrations/v22-to-v24.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ Node.js' `configure` script will warn if you attempt to build Node.js with a com

Some breaking changes or End of Life (EOL) deprecations in Node.js 23 and 24 have associated codemods to help you update your codebase. Below is a list of the available codemods for this migration:

If you wan't to run all of them at once, you can use the following command:
Comment thread
Copilot marked this conversation as resolved.
Outdated

```bash
npx codemod run @nodejs/v22-to-v24
```

<AlertBox level="info" title="!">
As said in the introduction, this is not a complete list of codemods for this migration.<br/>
</AlertBox>
Comment thread
Copilot marked this conversation as resolved.

### `crypto-rsa-pss-update`

In [DEP0154](https://nodejs.org/docs/latest/api/deprecations.html#DEP0154), the `generateKeyPair` and `generateKeyPairSync` methods in the `crypto` module deprecated the `hash`, `mgf1Hash`, and `saltLength` options for the `'rsa-pss'` key type in favor of `hashAlgorithm`, `mgf1HashAlgorithm`, and `saltLength` respectively.
Expand Down
Loading