Sean Massa's Labs

Updating npm Packages With Certainty

2024-01-22 #software-engineering

To find the best options for the installing/updating Node.js packages in all circumstances, I tested it locally and globally for npm, yarn 1, and pnpm.


Given a package is installed at a minor version behind latest, I ran the following commands with the goal of ensuring the latest version of the package was installed. I checked local/global variations on install, install @latest, and update commands.

Installed: "async": "1.0.0" Latest: async@3.2.4

Note: npx always (local and global) needs @latest to guarantee the latest version is used.


From the test results (see below), I think we can conclude:


Always use @latest. It's simpler and always works.

Updating <code>npm</code> Packages With Certainty | Sean Massa's Labs