Skip to main content

Handle Breaking Changes Gracefully

A collection of automated migration recipes (codemods) for Node.js userland code. Update your codebase to adopt new features and handle deprecations with confidence.

Quick Start

Get up and running with codemods in just a few steps

1

Commit your changes

Before running any codemod, commit your current work to version control. Codemods modify source code directly.
git add .
git commit -m "Save work before migration"
2

Run a migration recipe

Choose a migration recipe from the catalog and run it with the Codemod CLI. Replace <recipe> with the name of the recipe you want to run.
npx codemod @nodejs/<recipe>
✓ Found 8 files to transform
✓ Applied transformations
✓ Removed deprecated dependencies

Successfully migrated 8 files!
3

Review and test

Review the changes made by the codemod, run your tests, and ensure everything works as expected.
git diff
npm test
4

Commit the migration

Once you’ve verified the changes, commit them to your repository.
git add .
git commit -m "Migrate to new Node.js API"

Explore by Category

Find the right migration recipe for your use case

Buffer APIs

Migrate legacy buffer.atob() and buffer.btoa() to modern alternatives

File System

Update deprecated fs.rmdir() calls to fs.rm() with recursive option

Crypto APIs

Migrate deprecated crypto.fips to crypto.getFips() and crypto.setFips()

Utilities

Replace deprecated util.is* methods with modern alternatives

TypeScript

Correct import specifiers for Node.js ESM compliance

Process APIs

Migrate process.mainModule to require.main

Key Features

Why use Node.js Userland Migrations

AST-Based Transformations

Powered by ast-grep and jssg API for accurate, safe code transformations that understand your code structure.

Automatic Dependency Management

Automatically removes deprecated packages from package.json when migrating to built-in Node.js APIs.

CommonJS & ESM Support

Works with both CommonJS (require) and ES modules (import), ensuring compatibility with your module system.

28 Migration Recipes

Comprehensive coverage of Node.js breaking changes across buffer, crypto, fs, util, and more.

Resources

Core Concepts

Learn how codemods work and when to use them

Developer Guide

Contribute new recipes and help improve the project

API Reference

Explore the utilities for building custom codemods

GitHub Repository

View the source code and contribute

Ready to Get Started?

Run your first migration in minutes and keep your Node.js codebase up to date with the latest best practices.

Get Started