[BUG] npx won't execute the latest version of a package (original) (raw)

Is there an existing issue for this?

This issue exists in the latest npm version

Current Behavior

I tried running npx ts-node@latest, but npx decided to execute a version of ts-node that is not the latest.

$ rm -rf ~/.npm
$ node --version
v18.7.0
$ npm --version
8.16.0
$ npx ts-node --version
v9.1.1
$ npx ts-node@latest --version
Need to install the following packages:
  ts-node@10.9.1
Ok to proceed? (y) y
v9.1.1

It even asks me if I want to install version 10.9.1, but then it runs version 9.1.1 anyway 😕

Expected Behavior

I expect npx <package>@latest to always run the latest version of a package.

Similarly, I expect npx <package>@<version> to always run the specified version. For example, npx ts-node@10 should run ts-node version 10

Steps To Reproduce

  1. Update node and npm to the latest versions.
  2. Try running npx ts-node@latest --version.
  3. It runs an older version
  4. Try deleting ~/.npm; same problem.
  5. Try globally uninstalling ts-node; same problem.
  6. Try locally uninstalling ts-node; same problem.

Environment

; node bin location = /usr/local/bin/node ; node version = v18.7.0 ; npm local prefix = /home/kkovacs/oss_97542 ; npm version = 8.16.0 ; cwd = /home/kkovacs/oss_97542 ; HOME = /home/kkovacs ; Run npm config ls -l to show all defaults.