Registry
Nnodejs avatar

nodejs/util-print-to-console-log

Handle DEP0026, DEP0027, DEP0028, DEP0029 via transforming `util.print|puts|debug|error()` to `console.log|error()`

nodejs92 executions

  • transformation
  • migration
Connect a repo
npx codemod @nodejs/util-print-to-console-log

util.print, util.puts, util.debug, util.error DEP0026,DEP0027,DEP0028,DEP0029

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

See DEP0026.
See DEP0027.
See DEP0028.
See DEP0029.

Example

diff
- const util = require("node:util");

- util.print("Hello world");
+ console.log("Hello world");
- util.puts("Hello world");
+ console.log("Hello world");
- util.debug("Hello world");
+ console.error("Hello world");
- util.error("Hello world");
+ console.error("Hello world");

Before:

js
const { print, error } = require("node:util");

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

After:

js
console.log("Application started");
console.error("Processing request");

Ready to evolve your codebase?

Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.