The `replace` utility is a command-line tool for performing search-and-replace operations across multiple files. It functions similarly to `sed` but distinguishes itself by directly modifying files when matches are found, offering recursive directory search capabilities, and leveraging JavaScript syntax for regular expressions and replacement strings. Additionally, it provides a `search` command that mimics `grep`'s functionality, utilizing the same JS-based regex patterns. The current stable version is 1.2.2. While its release cadence isn't explicitly defined, the version number suggests a mature, stable tool with infrequent updates. Its key differentiators include its direct file modification approach, ease of recursive operations, and the familiarity of JavaScript regex for developers. It also offers a programmatic API for integration into Node.js applications and includes default and customizable file exclusion patterns.
npm install replaceVerified import paths — ran on the pinned version, not inferred.
Demonstrates programmatic search and replace within a specified directory using JavaScript regular expression syntax.
Ensure that npm's global binaries directory is prioritized in your system's PATH environment variable, or invoke the utility explicitly via `npx replace` or `node $(npm root -g)/replace/bin/replace`.
Use the quiet flag (`-q`), include only necessary file types with `--include="*.js"`, or limit lines shown in preview with `-n` to improve performance.
Familiarize yourself with JavaScript's `RegExp` and `String.prototype.replace()` documentation, especially regarding capture groups (`$1`, `$2`, etc.) and special characters.
Adjust your system's PATH environment variable to prioritize npm's global binaries, or use `npx replace` to ensure the correct executable is run.
No dependency data recorded yet.