Skip to main content

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 types.isNativeError to use Error.isError() to handle Node.js DEP0197.

What It Does

This codemod replaces:
  • types.isNativeError() calls with Error.isError()
  • Removes unnecessary util imports when no longer needed

Before/After

Before:
import { types } from "node:util";

if (types.isNativeError(err)) {
  // handle the error
}
After:
if (Error.isError(err)) {
  // handle the error
}

Usage

Run this codemod on your project:
npx codemod node/userland/types-is-native-error
Error.isError() is now the preferred way to check if a value is an Error object. This method is available globally without requiring any imports.

Build docs developers (and LLMs) love