Urgent.News

What's breaking now, across hundreds of outlets.

Tech

What Changed in This npm Release? Compare the Tarballs Before Upgrading

A dependency upgrade can change more than the function your application imports. It might add an install script, move a command-line entry point, or ship a directory that was absent from the previous release. The changelog gives you the author's explanation. Comparing the two published tarballs shows the changes your application will actually receive. Start with the exact version in your lockfile…

When upgrading an npm dependency, the new release may introduce changes beyond just the imported function. These changes could include adding an install script, altering a command-line entry point, or introducing a directory absent in the previous version. To understand these modifications, it's essential to compare the two released tarballs.

Using the exact version from your lockfile and the proposed replacement, avoid using tags like 'latest'. Keep both archives until the upgrade decision is documented. Store each release in separate directories and use npm and a Linux or WSL shell with tar, sort, diff, and sha512sum to perform the comparison. Save the compare-release.sh script and run it with the exact name@version arguments from the upgrade proposal.

The script downloads the archives and reads their contents without installing the packages. npm pack allows you to save the tarball to a chosen directory and supports JSON output. The --ignore-scripts flag suppresses lifecycle execution for this operation. Once the archives are downloaded, compare the sorted lists of files to identify added or removed paths.

Then, examine the package.json files and the SHA-512 checksums of the archives to understand the changes in the manifest and the package itself. During the review process, address specific questions about the lifecycle scripts, entry points, dependencies, and file additions or removals. For instance, if the postinstall script now invokes scripts/setup.js, investigate what this script does and why it's necessary for this release.

Similarly, if the main, exports, or bin fields have changed, evaluate how these changes affect imports or command-line invocations. Compare the dependencies, optionalDependencies, and peerDependencies separately to determine if new runtime dependencies or updated peer requirements require additional upgrade work. If new executable paths are introduced, verify that the corresponding files exist in the archive listing.

Any unexplained changes should remain open items in the upgrade review. After comparing the two releases, attach the artifact identities, including the exact package specifications, npm's pack output, archive checksums, and review notes. This documentation provides a clear understanding of what changed in the new release.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

More from Saturday, 28 November 2026 →