diff --git a/apps/site/pages/en/blog/migrations/v16-to-v18.mdx b/apps/site/pages/en/blog/migrations/v16-to-v18.mdx index b469c14b80ee2..62729ecb0e753 100644 --- a/apps/site/pages/en/blog/migrations/v16-to-v18.mdx +++ b/apps/site/pages/en/blog/migrations/v16-to-v18.mdx @@ -16,6 +16,32 @@ 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 reached 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. + +You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/dns-lookup-options-coercion). + +```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. @@ -28,7 +54,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 { diff --git a/apps/site/pages/en/blog/migrations/v22-to-v24.mdx b/apps/site/pages/en/blog/migrations/v22-to-v24.mdx index 63478577ac4e8..a52bfba83fbab 100644 --- a/apps/site/pages/en/blog/migrations/v22-to-v24.mdx +++ b/apps/site/pages/en/blog/migrations/v22-to-v24.mdx @@ -69,6 +69,17 @@ 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 want to run all of them at once, you can use the following command: + +```bash +npx codemod run @nodejs/v22-to-v24 +``` + + + As noted in the introduction, this is not a complete list of codemods for this + migration. + + ### `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.