This is an npm module for using ripgrep in a Node project. It's used by VS Code.
- Ripgrep is built in microsoft/ripgrep-prebuilt and published as release assets for each tag.
- At publish time, the binaries for every supported platform are downloaded by
build/prepare-binaries.js, verified againstbinaries.lock.json(SHA256), and placed underbin/<target>/rg[.exe]. They ship inside the npm tarball. - At runtime,
lib/index.jsresolvesrgPathfromprocess.platform/process.archto the correctbin/<target>/<binary>. - There is no
postinstallstep and no runtime network access.
const { rgPath } = require('@vscode/ripgrep');
// child_process.spawn(rgPath, ...)This monorepo publishes three kinds of npm packages:
@vscode/ripgrep— the normal entry point. Pure JS wrapper; pulls in the per-platform binary package for the current platform viaoptionalDependencies. Use this for almost everything.@vscode/ripgrep-<os>-<cpu>— the per-platform binary packages (e.g.@vscode/ripgrep-linux-x64). Installed transitively by@vscode/ripgrep. Not meant to be depended on directly.@vscode/ripgrep-universal— a single tarball bundling every platform's binary. Use this when you need access to all platforms' binaries from one install — for example, when repackaging an app into cross-platform artifacts from one build host. ExportsrgPath(current platform) andbinPathFor({ os, arch })(any platform). Tarball is large (~60 MB).
- Edit the
VERSION(orMULTI_ARCH_VERSION) constant inlib/platforms.js. - Run
npm run update-lock. This re-downloads every platform's archive and rewritesbinaries.lock.jsonwith the fresh SHA256 hashes. - Commit the updated
lib/platforms.jsandbinaries.lock.json.
npm run prepare-binaries— downloads any missing binaries and verifies them againstbinaries.lock.json. Fails on hash mismatch.npm run prepare-binaries -- --force— forces a clean re-download (still verifies).npm run update-lock— refreshesbinaries.lock.jsonafter a version bump.
Set GITHUB_TOKEN to avoid GitHub's anonymous API rate limit during downloads.