Skip to content

Commit 81ee06b

Browse files
update
1 parent 17bcae9 commit 81ee06b

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

apps/site/pages/en/learn/userland-migrations/introduction.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Official migrations are published under the `@nodejs` scope within the [Codemod
1616

1717
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.
1818

19-
## How to use a Codemod
19+
## How to use a codemod
2020

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

@@ -37,6 +37,11 @@ npx codemod @nodejs/import-assertions-to-attributes
3737
- **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
3838
- **Format and or lint your code**: After running a migration, it is a good practice to format and lint your code. This ensures that your code follows the project's coding standards and is easier to read and maintain.
3939

40+
## Understanding Codemods Registry
41+
42+
The [Codemod registry](https://codemod.link/nodejs-official) provides a list of available codemods for Node.js.
43+
Some codemods may not be included in the following resources but are still available because they are not related to a specific migration to a Node.js version. Since we only list codemods for EoL deprecations, you may need to explore the registry for other codemods that could be useful for your migrations.
44+
4045
## Feedback
4146

4247
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).
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
title: Node.js v12 to v14
3+
layout: learn
4+
authors: AugustinMauroy
5+
---
6+
7+
# Node.js v12 to v14
8+
9+
This page provides a list of codemods to help you migrate your code from Node.js v12 to v14.
10+
11+
## `util-print-to-console-log`
12+
13+
This recipe transforms the usage of log functions from util, `print`, `puts`, `debug`, `error` to use `console.log()` or `console.error()`.
14+
15+
So this codemod handle [DEP0026](https://nodejs.org/api/deprecations.html#DEP0026), [DEP0027](https://nodejs.org/api/deprecations.html#DEP0027), [DEP0028](https://nodejs.org/api/deprecations.html#DEP0028) and [DEP0029](https://nodejs.org/api/deprecations.html#DEP0029).
16+
17+
```bash
18+
npx codemod run @nodejs/create-require-from-path
19+
```
20+
21+
### Example:
22+
23+
```js displayName="Before"
24+
const util = require('node:util');
25+
26+
util.print('Hello world');
27+
util.puts('Hello world');
28+
util.debug('Hello world');
29+
util.error('Hello world');
30+
```
31+
32+
```js displayName="After"
33+
console.log('Hello world');
34+
console.log('Hello world');
35+
console.error('Hello world');
36+
console.error('Hello world');
37+
```

0 commit comments

Comments
 (0)