[BUG] npx does not attempt to get newer versions
Problem
Current Behavior: I have been using `npx <some-workflow-helper>` over the past year to run the current version of a command without having to manage updating it. npm7 does not pull the latest version if I have run it once before... i suspect because its no longer a temp install... Expected Behavior: `npx some-package` always runs the latest published version. Steps To Reproduce: 1. `npx <test-package>` 2. publish a new version of <test-package> 3. `npx <test-package>` Environment: - OS: Fedora 33 - Node: 14.15.0 - npm: 7.1.0
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Force npx to Fetch Latest Package Version
The issue arises because npx caches the last used version of a package, preventing it from fetching the latest version on subsequent runs. This behavior is due to npm's design where it prioritizes efficiency by avoiding repeated downloads of the same package unless explicitly instructed to do so.
Awaiting Verification
Be the first to verify this fix
- 1
Clear npx cache
Clear the npx cache to ensure that the next invocation fetches the latest version of the package.
bashnpx cache clear - 2
Use npx with the latest flag
Run npx with the --latest flag to explicitly request the latest version of the package.
bashnpx --latest <test-package> - 3
Update npm to the latest version
Ensure that you are using the latest version of npm, as newer versions may have bug fixes or improvements related to npx and package fetching.
bashnpm install -g npm@latest - 4
Check for global installations
Verify if the package is installed globally, as this may affect the version npx uses. If it is, consider uninstalling the global version.
bashnpm uninstall -g <test-package> - 5
Test the package after changes
After performing the above steps, run the package again to confirm that the latest version is being fetched and executed.
bashnpx <test-package>
Validation
To confirm the fix worked, run 'npx <test-package>' and check if the output reflects the latest version published. You can also verify the version by checking the package's release notes or changelog.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep