rnpm is a research prototype for verifiable dependency resolution in npm. It records resolution evidence in the lockfile and uses that evidence to regenerate and compare dependency graphs.
Use Node.js and npm in a Linux environment. The prototype was evaluated using Windows Subsystem for Linux (WSL2), with kernel version 5.15.167.4-microsoft-standard-WSL2.
Verification may install the npm versions recorded in the lockfile. Use a user-writable npm global prefix, for example through a Node.js version manager.
Using HTTPS:
git clone https://github.com/chains-project/rnpm.git
cd rnpm
npm linkUsing SSH (with GitHub SSH access configured):
git clone git@github.com:chains-project/rnpm.git
cd rnpm
npm linkRun the automated test suite from the repository root:
npm testThe tests cover command history recording, command replay, manifest and lockfile restoration, dependency graph comparison, and verification behavior.
The supported commands are install (i), uninstall (remove, rm, un), init, update, and verify.
Use the following npm flags to generate lockfiles without installing dependencies or executing lifecycle scripts:
--package-lock-only--ignore-scripts
Both flags are applied automatically during verification.
Use the default npm registry. Custom registries (--registry) are not supported. Other npm flags are not guaranteed to be supported during replay.
--regen: Regenerate the lockfile instead of reusing an existingrnpm-replication.json.--non-interactive(alias--yes): Run verification without interactive confirmation, regenerating the lockfile rather than reusing an existing one.--keep-npm: Do not restore the npm version that was active before verification.
By default, if rnpm-replication.json already exists, rnpm verify prompts the user to compare the existing file or regenerate it. Reusing the existing file performs comparison without repeating dependency resolution.
mkdir tst
cd tst
rnpm init -y
rnpm install react --package-lock-only --ignore-scripts
rnpm verifyIf verification succeeds, the terminal displays:
Verification completed
rnpm extends the lockfile produced by npm with the following fields:
manifestIntegrity: SHA-256 digest ofpackage.json, used to detect changes to the manifest since the last recorded operation. This digest does not establish the correctness of dependency resolution.rnpm: Metadata used for regeneration and verification.history: Ordered sequence of recorded commands used during replay. Each entry contains:command: npm command (e.g.installorupdate).args: Command-line arguments.npm: npm version used for the command.time: Resolution timestamp in RFC 3339 format (e.g.2026-03-17T15:18:17.497Z). During replay, this timestamp is supplied to npm through the--beforeflag forinstallandupdatecommands.
The lockfile regenerated during verification, without the additional rnpm and manifestIntegrity fields. It is used for comparison with the original lockfile.
The npm commands supported by rnpm retain their corresponding npm functionality and record resolution evidence in package-lock.json. Unlike npm init, rnpm init also creates a lockfile.
The verify command replays the recorded history using the recorded npm versions and resolution timestamps. It compares the resulting logical dependency graph, dependency types, package sources, and tarball integrity values with those in the original lockfile. A mismatch or failed verification is reported with a non-zero exit status.
A successful comparison establishes correspondence between the compared graphs under the replay conditions; it does not authenticate the recorded history or establish that the original resolution was free from manipulation.
Dependency resolution in npm is iterative. The resulting lockfile depends on both the sequence of resolution commands and the state of the package registry at the time of each command.
Consider the following example, assuming no other dependency constraints:
- Run
npm install pkgAwhen version1.0.0is the latest release. npm addspkgA: ^1.0.0topackage.jsonand recordspkgA@1.0.0in the lockfile. pkgA@1.0.1is published.pkgB@1.0.0is published.- Run
npm install pkgB. npm addspkgB: ^1.0.0topackage.jsonand recordspkgB@1.0.0in the lockfile, retainingpkgA@1.0.0. - Resolving the dependencies from the final manifest alone, without the existing lockfile, can instead select
pkgA@1.0.1andpkgB@1.0.0.
The final manifest does not preserve the sequence of commands or their resolution conditions. rnpm records this information to support later dependency graph regeneration. Historical registry state must also remain recoverable for regeneration to succeed.