NPM install @latest does not install latest version of package

836 Views Asked by At

I'm trying to install a package which our company built. In package.json it's listed in the dependencies as:

"package-name": "latest"

Our current latest version is 3.5.0, which I can see when I run npm show package-name versions. However when I run npm install package-name@latest, version 3.2.3 is installed. Before version 3.2.3, everything worked fine. It always used the latest version up until that point.

I've checked for differences between the 3.2.3 package and the 3.5.0, but I can't find any.

I tried deleting the package (including package-lock.json) and reinstalling it. We've also updated the package itself a couple of times, but for installing, it keeps using version 3.2.3.

We use MyGet package manager, 3.5.0 is flagged as the latest version. How can we get npm install to target the correct latest version instead of the outdated one?

1

There are 1 best solutions below

0
On

Taken from npm's documentation:

By default, running npm publish will tag your package with the latest dist-tag.

If you maintain older versions of this package, then version 3.2.3 may have been published after 3.5.0 along with this default dist-tag.

The command npm install package-name@latest is actually just asking for the version with the latest dist-tag attached and so would install 3.2.3 rather than 3.5.0.

The dist-tag command can be used to set the latest tag against the correct version.