From 71611bb522c21886d34ae5abb7cb52fad95fc978 Mon Sep 17 00:00:00 2001 From: Augustin Mauroy <97875033+AugustinMauroy@users.noreply.github.com> Date: Sun, 9 Aug 2026 23:10:21 +0200 Subject: [PATCH 1/4] blog: migration remove not node version related --- .../en/blog/migrations/axios-to-fetch.mdx | 170 ------------------ .../en/blog/migrations/chalk-to-styletext.mdx | 69 ------- 2 files changed, 239 deletions(-) delete mode 100644 apps/site/pages/en/blog/migrations/axios-to-fetch.mdx delete mode 100644 apps/site/pages/en/blog/migrations/chalk-to-styletext.mdx diff --git a/apps/site/pages/en/blog/migrations/axios-to-fetch.mdx b/apps/site/pages/en/blog/migrations/axios-to-fetch.mdx deleted file mode 100644 index 518d5a3d07c1b..0000000000000 --- a/apps/site/pages/en/blog/migrations/axios-to-fetch.mdx +++ /dev/null @@ -1,170 +0,0 @@ ---- -date: '2026-05-09T00:00:00.000Z' -category: migrations -title: Axios to WHATWG Fetch -layout: blog-post -author: AugustinMauroy ---- - -# Migrate from Axios to WHATWG Fetch - -This codemod transforms code using [Axios](https://github.com/axios/axios) to leverage the [WHATWG Fetch API](https://fetch.spec.whatwg.org/), which is now natively available in Node.js. - -## Why doing this? - -- **Native Support**: Fetch is built into Node.js, eliminating the need for external libraries and their associated maintenance overhead. -- **Improved Performance**: Fetch is optimized for modern JavaScript runtimes, often resulting in better performance compared to Axios. -- **Better Standards Compliance**: Fetch adheres closely to web standards, making it easier to write cross-platform code that works both in Node.js and browsers. -- **Reduced Security Risks**: Removing Axios eliminates potential vulnerabilities associated with third-party dependencies, enhancing the security of your application. - -## Node.js Version Requirements - -- Node.js v18.0.0 or later (Fetch API is available but marked experimental) -- Node.js v21.0.0 or later (Fetch API is stable) - -> If your package currently supports Node.js versions earlier than v18.0.0, you cannot migrate to the Fetch API without dropping support for those versions. -> This requires bumping the major version of your package AND updating the engines field in your package.json to require Node.js >= v18.0.0. - -## Supported Transformations - -The codemod supports the following Axios methods and converts them to their Fetch equivalents: - -- `axios.request(config)` -- `axios.get(url[, config])` -- `axios.delete(url[, config])` -- `axios.head(url[, config])` -- `axios.options(url[, config])` -- `axios.post(url[, data[, config]])` -- `axios.put(url[, data[, config]])` -- `axios.patch(url[, data[, config]])` -- `axios.postForm(url[, data[, config]])` -- `axios.putForm(url[, data[, config]])` -- `axios.patchForm(url[, data[, config]])` - -## Usage - -The source code for this codemod can be found in the [axios-to-whatwg-fetch directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/axios-to-whatwg-fetch). - -You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/axios-to-whatwg-fetch). - -```bash -npx codemod @nodejs/axios-to-whatwg-fetch -``` - -## Examples - -### GET Request - -```diff -const base = 'https://dummyjson.com/todos'; - -- const all = await axios.get(base); -+ const all = await fetch(base).then(async (res) => Object.assign(res, { data: await res.json() })).catch(() => null); - console.log('\nGET /todos ->', all.status); - console.log(`Preview: ${all.data.todos.length} todos`); -``` - -### POST Request - -```diff -const base = 'https://dummyjson.com/todos'; - -- const created = await axios.post( -- `${base}/add`, { -- todo: 'Use DummyJSON in the project', -- completed: false, -- userId: 5, -- }, { -- headers: { 'Content-Type': 'application/json' } -- } -- ); -+ const created = await fetch(`${base}/add`, { -+ method: 'POST', -+ headers: { 'Content-Type': 'application/json' }, -+ body: JSON.stringify({ -+ todo: 'Use DummyJSON in the project', -+ completed: false, -+ userId: 5, -+ }), -+ }).then(async (res) => Object.assign(res, { data: await res.json() })); - console.log('\nPOST /todos/add ->', created.status); - console.log('Preview:', created.data?.id ? `created id ${created.data.id}` : JSON.stringify(created.data).slice(0,200)); -``` - -### POST Form Request - -```diff -const formEndpoint = '/submit'; - -- const created = await axios.postForm(formEndpoint, { -- title: 'Form Demo', -- completed: false, -- }); -+ const created = await fetch(formEndpoint, { -+ method: 'POST', -+ body: new URLSearchParams({ -+ title: 'Form Demo', -+ completed: false, -+ }), -+ }).then(async (res) => Object.assign(res, { data: await res.json() })); - console.log('Preview:', created.data); -``` - -### PUT Request - -```diff -const base = 'https://dummyjson.com/todos'; - -- const updatedPut = await axios.put( -- `${base}/1`, -- { completed: false }, -- { headers: { 'Content-Type': 'application/json' } } -- ); -+ const updatedPut = await fetch(`${base}/1`, { -+ method: 'PUT', -+ headers: { 'Content-Type': 'application/json' }, -+ body: JSON.stringify({ completed: false }), -+ }).then(async (res) => Object.assign(res, { data: await res.json() })); - console.log('\nPUT /todos/1 ->', updatedPut.status); - console.log('Preview:', updatedPut.data?.completed !== undefined ? `completed=${updatedPut.data.completed}` : JSON.stringify(updatedPut.data).slice(0,200)); -``` - -### DELETE Request - -```diff -const base = 'https://dummyjson.com/todos'; - -- const deleted = await axios.delete(`${base}/1`); -+ const deleted = await fetch(`${base}/1`, { method: 'DELETE' }) -+ .then(async (res) => Object.assign(res, { data: await res.json() })); - console.log('\nDELETE /todos/1 ->', deleted.status); - console.log('Preview:', deleted.data ? JSON.stringify(deleted.data).slice(0,200) : typeof deleted.data); -``` - -### `request` Axios Method - -```diff -const base = 'https://dummyjson.com/todos'; - -- const customRequest = await axios.request({ -- url: `${base}/1`, -- method: 'PATCH', -- headers: { 'Content-Type': 'application/json' }, -- data: { completed: true }, -- }); -+ const customRequest = await fetch(`${base}/1`, { -+ method: 'PATCH', -+ headers: { 'Content-Type': 'application/json' }, -+ body: JSON.stringify({ completed: true }), -+ }).then(async (res) => Object.assign(res, { data: await res.json() })); -console.log('\nPATCH /todos/1 ->', customRequest.status); -console.log('Preview:', customRequest.data?.completed !== undefined ? `completed=${customRequest.data.completed}` : JSON.stringify(customRequest.data).slice(0,200)); -``` - -## Unsupported APIs - -The codemod does not yet cover Axios features outside of direct request helpers, such as interceptors, cancel tokens, or instance configuration from `axios.create()`. - -## Recognition - -We would like to thank the maintainers of [Axios](https://github.com/axios/axios) for their support of the package over time and for its contributions to the ecosystem. diff --git a/apps/site/pages/en/blog/migrations/chalk-to-styletext.mdx b/apps/site/pages/en/blog/migrations/chalk-to-styletext.mdx deleted file mode 100644 index 05c4400410892..0000000000000 --- a/apps/site/pages/en/blog/migrations/chalk-to-styletext.mdx +++ /dev/null @@ -1,69 +0,0 @@ ---- -date: '2026-01-23T00:00:00.000Z' -category: migrations -title: Chalk to Node.js util styleText -layout: blog-post -author: richiemccoll ---- - -# Migrate from Chalk to Node.js util styleText - -This codemod aims to help you reduce external dependencies by transforming chalk method calls to use the native Node.js styling functionality. It will also handle automatic removal of the [`chalk`](https://github.com/chalk/chalk) package from the package.json. - -## Compatible Features: - -- Basic colors (red, green, blue, yellow, etc.) -- Bright colors (redBright, greenBright, etc.) -- Background colors (bgRed, bgGreen, etc.) -- Text modifiers (bold, dim, italic, underline, strikethrough, etc.) -- Style chaining via array syntax -- Environment variable support (NO_COLOR, NODE_DISABLE_COLORS, FORCE_COLOR) - -## Incompatible Features: - -- Custom RGB colors (chalk.rgb(), chalk.hex()) -- 256-color palette (chalk.ansi256()) -- Template literal syntax (chalk...``) -- Advanced modifiers with limited terminal support (overline, blink, etc.) - -## Node.js Version Requirements - -- Node.js v20.12.0 or later (for util.styleText) -- `util.styleText` became stable in Node.js v22.13.0 (and v23.5.0) - -> If your package currently supports Node.js versions earlier than v20.12.0, you cannot migrate to util.styleText without dropping support for those versions. -> This requires bumping the major version of your package AND updating the engines field in your package.json to require Node.js >= v20.12.0. - -## Usage: - -The source code for this codemod can be found in the [chalk-to-util-styletext directory](https://github.com/nodejs/userland-migrations/tree/main/recipes/chalk-to-util-styletext). - -You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/chalk-to-util-styletext). - -```bash -npx codemod @nodejs/chalk-to-util-styletext -``` - -## Example: - -```diff -- import chalk from 'chalk'; -+ import { styleText } from 'node:util'; - -- console.log(chalk.red('Error message')); -+ console.log(styleText('red', 'Error message')); - -- console.log(chalk.green.underline('Success with emphasis')); -+ console.log(styleText(['green', 'underline'], 'Success with emphasis')); - -- const red = chalk.red; -+ const red = (text) => styleText('red', text); -- const boldBlue = chalk.blue.bold; -+ const boldBlue = (text) => styleText(['blue', 'bold'], text); -console.log(red('Error')); -console.log(boldBlue('Info')); -``` - -## Recognition - -We would like to thank the maintainers of [`chalk`](https://github.com/chalk/chalk) for their support of the package over time and for its contributions to the ecosystem. From 69a914d61bb2478a5d71caba5744d2b3e98a9df8 Mon Sep 17 00:00:00 2001 From: Augustin Mauroy <97875033+AugustinMauroy@users.noreply.github.com> Date: Sun, 9 Aug 2026 23:12:09 +0200 Subject: [PATCH 2/4] blog: remove author --- apps/site/authors.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/apps/site/authors.json b/apps/site/authors.json index 9934f96eb6dad..20217976eec33 100644 --- a/apps/site/authors.json +++ b/apps/site/authors.json @@ -233,11 +233,6 @@ "name": "Richard Lau", "website": "https://github.com/richardlau" }, - "richiemccoll": { - "id": 12698531, - "name": "Richie McColl", - "website": "https://github.com/richiemccoll" - }, "Robin Bender Ginn": { "id": 4296937, "name": "Robin Bender Ginn", From 7f1af00191cc25c61fdb01a8d83915479b43a7c0 Mon Sep 17 00:00:00 2001 From: Augustin Mauroy <97875033+AugustinMauroy@users.noreply.github.com> Date: Sun, 9 Aug 2026 23:17:12 +0200 Subject: [PATCH 3/4] blog: add redirect --- apps/site/redirects.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/site/redirects.json b/apps/site/redirects.json index f4c7aa77a1b52..adce3daba912f 100644 --- a/apps/site/redirects.json +++ b/apps/site/redirects.json @@ -251,6 +251,14 @@ { "source": "/:locale/download/package-manager/all", "destination": "/:locale/download/archive/current" + }, + { + "": ":locale/blog/migrations/axios-to-fetch", + "destination": "/learn/userland-migrations/axios-to-whatwg-fetch" + }, + { + "source": ":locale/blog/migrations/chalk-to-styletext", + "destination": "/learn/userland-migrations/chalk-to-util-styletext" } ], "internal": [] From 60e1ebfc868ae7c5ba00d6c733b2a5dcde2c2ac4 Mon Sep 17 00:00:00 2001 From: Augustin Mauroy <97875033+AugustinMauroy@users.noreply.github.com> Date: Sun, 9 Aug 2026 23:18:54 +0200 Subject: [PATCH 4/4] fix: redirect --- apps/site/redirects.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/site/redirects.json b/apps/site/redirects.json index adce3daba912f..ab7bbcc365150 100644 --- a/apps/site/redirects.json +++ b/apps/site/redirects.json @@ -253,11 +253,11 @@ "destination": "/:locale/download/archive/current" }, { - "": ":locale/blog/migrations/axios-to-fetch", + "source": "/:locale/blog/migrations/axios-to-fetch", "destination": "/learn/userland-migrations/axios-to-whatwg-fetch" }, { - "source": ":locale/blog/migrations/chalk-to-styletext", + "source": "/:locale/blog/migrations/chalk-to-styletext", "destination": "/learn/userland-migrations/chalk-to-util-styletext" } ],