Node.js migration recipes help you automatically update deprecated APIs, migrate from external packages to built-in modules, and adopt modern Node.js best practices. Each recipe is a targeted codemod that can be run independently.
Getting Started
All recipes are run using the codemod CLI tool:
npx codemod nodejs/<recipe-name>
Before running any migration recipe, commit your changes to version control. Codemods modify your source code directly.
Recipe Categories
Buffer & Encoding
Migrations related to buffer operations and encoding/decoding.
- buffer-atob-btoa - Migrate from legacy
buffer.atob() and buffer.btoa() to modern Buffer APIs
Crypto & Security
Migrations for cryptographic APIs and security-related deprecations.
File System
Migrations for file system API updates and deprecations.
Module System
Migrations related to CommonJS and ES modules.
TypeScript
Migrations specific to TypeScript codebases.
- correct-ts-specifiers - Fix TypeScript import specifiers to use correct file extensions for Node.js compatibility
External Dependencies
Migrations from third-party packages to Node.js built-in modules.
Common Usage Patterns
Run a Single Recipe
npx codemod nodejs/buffer-atob-btoa
Target Specific Files
npx codemod nodejs/chalk-to-util-styletext --target "src/**/*.js"
Dry Run (Preview Changes)
npx codemod nodejs/crypto-fips-to-getFips --dry
Run npx codemod --help to see all available options for controlling how codemods are applied.
Deprecation References
Many recipes address specific Node.js deprecation warnings (DEP codes). You can find the full list of deprecations in the official Node.js documentation.
Contributing
Found a bug or want to add a new recipe? Visit the Node.js Userland repository to contribute.