> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/nodejs/userland-migrations/llms.txt
> Use this file to discover all available pages before exploring further.

# util Print Functions to console

> Migrate deprecated util.print(), util.puts(), util.debug(), and util.error() to console equivalents

This recipe transforms the usage of deprecated log functions from util (`print`, `puts`, `debug`, `error`) to use `console.log()` or `console.error()`.

## What It Does

This codemod handles four deprecated util functions:

* `util.print()` → `console.log()`
* `util.puts()` → `console.log()`
* `util.debug()` → `console.error()`
* `util.error()` → `console.error()`

## Before/After

**Before:**

```javascript theme={null}
const util = require("node:util");

util.print("Hello world");
util.puts("Hello world");
util.debug("Hello world");
util.error("Hello world");
```

**After:**

```javascript theme={null}
console.log("Hello world");
console.log("Hello world");
console.error("Hello world");
console.error("Hello world");
```

### Destructured Imports

**Before:**

```javascript theme={null}
const { print, error } = require("node:util");

print("Application started");
error("Processing request");
```

**After:**

```javascript theme={null}
console.log("Application started");
console.error("Processing request");
```

## Usage

Run this codemod on your project:

```bash theme={null}
npx codemod node/userland/util-print-to-console-log
```

<Tip>
  Note that `util.debug()` and `util.error()` are replaced with `console.error()` (stderr), while `util.print()` and `util.puts()` are replaced with `console.log()` (stdout).
</Tip>

## Related Deprecations

* [DEP0026: util.print()](https://nodejs.org/api/deprecations.html#DEP0026)
* [DEP0027: util.puts()](https://nodejs.org/api/deprecations.html#DEP0027)
* [DEP0028: util.debug()](https://nodejs.org/api/deprecations.html#DEP0028)
* [DEP0029: util.error()](https://nodejs.org/api/deprecations.html#DEP0029)
