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.
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:
const util = require("node:util");
util.print("Hello world");
util.puts("Hello world");
util.debug("Hello world");
util.error("Hello world");
After:
console.log("Hello world");
console.log("Hello world");
console.error("Hello world");
console.error("Hello world");
Destructured Imports
Before:
const { print, error } = require("node:util");
print("Application started");
error("Processing request");
After:
console.log("Application started");
console.error("Processing request");
Usage
Run this codemod on your project:
npx codemod node/userland/util-print-to-console-log
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).