Skip to content

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 16 additions & 4 deletions apps/site/navigation.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,24 @@
}
}
},
"migrations": {
"label": "components.navigation.learn.migrations.links.migrations",
"userland-migrations": {
"label": "components.navigation.learn.userland-migrations.links.userland-migrations",
"items": {
"introduction": {
"link": "/learn/migrations/introduction",
"label": "components.navigation.learn.migrations.links.introduction"
"link": "/learn/userland-migrations/introduction",
"label": "components.navigation.learn.userland-migrations.links.introduction"
},
"ecosystem": {
"link": "/learn/userland-migrations/ecosystem",
"label": "components.navigation.learn.userland-migrations.links.ecosystem"
},
"v20-to-v22": {
"link": "/learn/userland-migrations/v20-to-v22",
"label": "components.navigation.learn.userland-migrations.links.v20-to-v22"
},
"v14-to-v16": {
"link": "/learn/userland-migrations/v14-to-v16",
"label": "components.navigation.learn.userland-migrations.links.v14-to-v16"
}
}
},
Expand Down
28 changes: 0 additions & 28 deletions apps/site/pages/en/learn/migrations/introduction.md

This file was deleted.

25 changes: 25 additions & 0 deletions apps/site/pages/en/learn/userland-migrations/ecosystem.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of this file?

Copy link
Member Author

@AugustinMauroy AugustinMauroy Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second part of your goal like. It's will host all codemod related to ecosystem not specific node version

  • jest-to-node-test (pr opened)
  • mocha-to-node-test (issue opened)
  • axios-to-fetch (in my brain)
  • correct-ts-specifiers (released)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we outsource this list, since it'll change often, i.e. in the main file, have a paragraph about "Ecosystem" upgrades, and "Migration" upgrades, with a link to the list of each in the Codemod repository? This'll also resolve my concern at #8053 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah it's solve that. But why I'm doing this pr is to use your cool UI to show our codemod

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: Ecosystem to Node.js
layout: learn
authors: AugustinMauroy
---

# Ecosystem to Node.js

Sometimes the ecosystem creates awesome tools or libraries for node.js, but a native alternative is present in Node.js. So, this page shows you codemod that handle this case.

## `correct-ts-specifiers`

When you want to [run typescript natively in Node.js](/learn/typescript/run-natively), you need to have a correct "specifiers" in your [imports statements](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import).

To run this codemdod, you have to use this command:
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The word 'codemdod' should be 'codemod'.

Suggested change
To run this codemdod, you have to use this command:
To run this codemod, you have to use this command:

Copilot uses AI. Check for mistakes.


```bash
npx codemod@latest run correct-ts-specifiers
```

> **Note:** This codemod use "legacy" codemod CLI, if you wan to undersant more about it, you can read the [new codemod CLI announcement](https://codemod.com/blog/new-codemod-cli).
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple spelling errors: 'use' should be 'uses', 'wan' should be 'want', and 'undersant' should be 'understand'.

Suggested change
> **Note:** This codemod use "legacy" codemod CLI, if you wan to undersant more about it, you can read the [new codemod CLI announcement](https://codemod.com/blog/new-codemod-cli).
> **Note:** This codemod uses the "legacy" codemod CLI. If you want to understand more about it, you can read the [new codemod CLI announcement](https://codemod.com/blog/new-codemod-cli).

Copilot uses AI. Check for mistakes.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can safely remove this "Note" section. it adds unnecessary confusion. Users don’t need to know which CLI is being used. When they run npx codemod@latest <codemod-name>, we automatically choose the right one behind the scenes. Both the new and old CLIs are wrapped and fully backward compatible. cc @mohbifar


## Feedback

If you have any tools that you would like to be handle by userland-migrations, please open an issue on the [Node.js Userland Migrations repository](https://github.com/nodejs/userland-migrations/issues).
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The phrase 'to be handle' should be 'to be handled'.

Suggested change
If you have any tools that you would like to be handle by userland-migrations, please open an issue on the [Node.js Userland Migrations repository](https://github.com/nodejs/userland-migrations/issues).
If you have any tools that you would like to be handled by userland-migrations, please open an issue on the [Node.js Userland Migrations repository](https://github.com/nodejs/userland-migrations/issues).

Copilot uses AI. Check for mistakes.

74 changes: 74 additions & 0 deletions apps/site/pages/en/learn/userland-migrations/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
title: Userland Migrations
layout: learn
authors: JakobJingleheimer, AugustinMauroy
---

![Node.js Userland Migrations](https://raw.githubusercontent.com/nodejs/userland-migrations/main/.github/assets/Userland-Migration-Tagline.png)

# Userland Migrations

Node.js provides migrations for "userland" (what you write vs node's own) source-code to facilitate adoption of new features and upgrading source-code affected by breaking changes. These are done in collaboration with [`codemod`](https://docs.codemod.com/introduction), who also work with other major projects like Next.js, React, and Tailwind. Node.js's migrations live in the [`nodejs/userland-migrations`](https://github.com/nodejs/userland-migrations) repository and are overseen by the `@nodejs/userland-migrations` team.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Node.js provides migrations for "userland" (what you write vs node's own) source-code to facilitate adoption of new features and upgrading source-code affected by breaking changes. These are done in collaboration with [`codemod`](https://docs.codemod.com/introduction), who also work with other major projects like Next.js, React, and Tailwind. Node.js's migrations live in the [`nodejs/userland-migrations`](https://github.com/nodejs/userland-migrations) repository and are overseen by the `@nodejs/userland-migrations` team.
Node.js provides migrations for "userland"(anything not included in the `node` executable itself) to facilitate the adoption of new features and breaking changes. These are done in collaboration with [Codemod](https://docs.codemod.com/introduction), a company that specializes in xyz.
For Node.js, migrations live in https://github.com/nodejs/userland-migrations, and are overseen by the project itself.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this paragraph was originally written by @JakobJingleheimer so let's see his opinon

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some alternative:

Node.js offers migrations for "userland" code (anything outside the node executable) to help adopt new features and handle breaking changes. These are built in collaboration with Codemod, a company focused on making it easy to build, share, and run codemods.


<!--
maintainer node: https://codemod.link/nodejs-official is pointing to legacy codemod registry
it's will point to new new one once codemod change the redirection of the short link
-->
Comment on lines +13 to +16
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like that we have a maintainer note, can we can an ETA on this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

@alexbit-codemod alexbit-codemod Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed with Aviv. we don’t need to have such a note.

We, the Codemod team, will update the same shortlink on August 8, 2025 to point to the new registry.

(Besides link usage analytics, a key reason we use shortlinks is to avoid the maintenance overhead of updating links for users.)

cc @mohebifar


Official migrations are published under the `@nodejs` namespace within the [codemod registry](https://codemod.link/nodejs-official). These have been reviewed and/or authored by Node.js members. There are also unofficial migrations available which have not been reviewed by Node.js.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Official migrations are published under the `@nodejs` namespace within the [codemod registry](https://codemod.link/nodejs-official). These have been reviewed and/or authored by Node.js members. There are also unofficial migrations available which have not been reviewed by Node.js.
Official migrations (migrations that have been developed with Node.js project oversight) are published under the [`@nodejs`][...] scope within the [Codemod registry][...].


## Our goal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Our goal
## Goal


First our goal is to help you to migrate your codebase to the latest Node.js version. We want to make it easier for you to adopt new features, deprecations, and breaking changes. In summary, we want to help you to migrate your codebase to the latest Node.js version.

Second, we want to help you to adopt native Node.js features that are already available in the ecosystem. For example, if you are using a library that provides a feature that is already available in Node.js, we want to help you to migrate to the native Node.js feature.
Comment on lines +22 to +24
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
First our goal is to help you to migrate your codebase to the latest Node.js version. We want to make it easier for you to adopt new features, deprecations, and breaking changes. In summary, we want to help you to migrate your codebase to the latest Node.js version.
Second, we want to help you to adopt native Node.js features that are already available in the ecosystem. For example, if you are using a library that provides a feature that is already available in Node.js, we want to help you to migrate to the native Node.js feature.
The Node.js Userland Migrations team seeks to help developers migrate their codebases to the latest Node.js versions, making it easier to handle deprecations, new features, and breaking changes.


## How to use a Codemod

To use a codemod, you can run the following command in your terminal:

```bash displayName="npm"
npx codemod@next <codemod-name>
```
Comment on lines +30 to +32
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's only showcase npm

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ? On download we explain how to install yarn pnpm so why not on this page show them

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because if we showcase them, we are responsible for making that code work for our users. We are responsible for npm, not the other package managers

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oof right


```bash displayName="yarn"
yarn dlx codemod@next <codemod-name>
```

```bash displayName="pnpm"
pnpx codemod@next <codemod-name>
```

Replace `<codemod-name>` with the name of the codemod you want to run. For example, if you want to run the `@nodejs/import-assertions-to-attributes` codemod on your project, you would run:

```bash displayName="npm"
npx codemod@next @nodejs/import-assertions-to-attributes
```

```bash displayName="yarn"
yarn dlx codemod@next @nodejs/import-assertions-to-attributes
```

```bash displayName="pnpm"
pnpx codemod@next @nodejs/import-assertions-to-attributes
```

## Good Practices

- **Run migrations in a separate branch**: If you are using a version control system like Git, it is a good practice to run migrations in a separate branch. This allows you to review the changes before merging them into your main branch.
- **Review changes**: After running a migration, review the changes made to your codebase. Ensure that the migration has not introduced any unintended side effects or issues.
- **Test your code**: After running a migration, it is important to test your code to ensure that everything is working as expected. Run your test suite and check for any errors or failures

## Feedback

If you have any feedback or suggestions for improvements, please open an issue on the [Node.js Userland Migrations repository](https://github.com/nodejs/userland-migrations/issues).

## Follow the Userland Migrations Progression

You can follow the progress of userland migrations on our [GitHub project board](https://github.com/orgs/nodejs/projects/13/views/1).

This board tracks:

- Codemod kind (deprecation, breaking change, ecosystem)
- Node.js version
- Status (backlog, todo, in progress, done, not planned) _If you want to contribute, please check the "todo" column_
79 changes: 79 additions & 0 deletions apps/site/pages/en/learn/userland-migrations/v14-to-v16.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to add an article for each version upgrade. IMO such articles should be blog posts / on the Codemod repository

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

react make it as a blog post https://react.dev/blog/2024/04/25/react-19-upgrade-guide
next as a doc page https://nextjs.org/docs/app/guides/upgrading/version-15
fastify do it as doc https://fastify.dev/docs/latest/Guides/Migration-Guide-V3/

So IMO here it's goo area. Also not that we cannot touch to release note

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's very different. A "doc" is different than an "article". The docs change from version to version. Articles here do not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
title: Nodejs v14 to v16
layout: learn
authors: AugustinMauroy
---

# Nodejs v14 to v16

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

## `create-require-from-path`

In Node.js v16, the `createRequire` function was introduced to allow you to create a `require` function that can be used in ESM modules. This codemod will help you replace the old `createRequireFromPath` function with the new `createRequire` function.

So this codemod handle [DEP0130](https://nodejs.org/api/deprecations.html#DEP0130).

```bash
npx codemod@latest @nodejs/create-require-from-path
```

Example:

**Before:**

```js
import { createRequireFromPath } from 'node:module';

// Using createRequireFromPath
const requireFromPath = createRequireFromPath('/path/to/module');
const myModule = requireFromPath('./myModule.cjs');
```

**After:**

```js
import { createRequire } from 'node:module';

// Using createRequire with a specific path
const require = createRequire('/path/to/module');
const myModule = require('./myModule.cjs');
```

## `rmdir`

In Node.js v16, 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@latest @nodejs/rmdir
```

Example:

**Before:**

```js
// 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 });
```

**After:**

```js
// 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 });
```
29 changes: 29 additions & 0 deletions apps/site/pages/en/learn/userland-migrations/v20-to-v22.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: Nodejs v20 to v22
layout: learn
authors: AugustinMauroy
---

# Nodejs v20 to v22

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 removed and replaced with an `with` attribute on the `import` statement.
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The phrase 'but during the during the transition' contains a duplicated word 'during'. It should be 'but during the transition'.

Suggested change
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 removed and replaced with an `with` attribute on the `import` statement.
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 transition to stage 4, the `assert` keyword was removed and replaced with an `with` attribute on the `import` statement.

Copilot uses AI. Check for mistakes.


So in [node.js v22](https://nodejs.org/fr/blog/release/v22.0.0#other-notable-changes), the `import assert` feature was removed and you need to use the `with` attribute 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.
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The word 'introduce' should be 'introduced' (past participle form) and 'as' should be 'has'.

Suggested change
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.
Also note that the `with` keyword has been introduced 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.

Copilot uses AI. Check for mistakes.


```bash
npx codemod@latest @nodejs/import-assertions-to-attributes
```

Example:

```js
import jsonData from './data.json' assert { type: 'json' };
// becomes
import jsonData from './data.json' with { type: 'json' };
```
9 changes: 6 additions & 3 deletions packages/i18n/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,13 @@
"acceptInputFromTheCommandLineInNodejs": "Accept input from the command line in Node.js"
}
},
"migrations": {
"userland-migrations": {
"links": {
"migrations": "Userland Migrations",
"introduction": "Introduction to Userland Migrations"
"userland-migrations": "Userland Migrations",
"introduction": "Introduction to Userland Migrations",
"ecosystem": "Ecosystem to Node.js",
"v20-to-v22": "Node.js v20 to v22",
"v14-to-v16": "Node.js v14 to v16"
}
},
"modules": {
Expand Down
Loading