-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] npx isn't using latest version of package #4108
Comments
If I temporarily rename I don't know how the caching works exactly, but maybe the checksum (or whatever it is) is calculated wrongly sometimes or something.
IDK, but I just found it a little weird that |
I had the same issue with a cli that I'm developing. When I called npx, it used an old version instead of the new one until I deleted the npx cache (~/.npm/_npx). After cache deletion I tried first to use an old version to download it and after the new one but now it is working as expected. So try to remove the npx cache. Actually I'm developing an e2e test using a private registry to test that cli and it is not working as expected. I publish the package without updating the version to the private registry (without any package and without proxy this package to the official registry), then when I call npx with the private registry it uses the version of the official registry because it is in the cache. I fixed this issue removing the npx cache before the e2e test. The bug that I see (similar to this opened issue) is that npx cache don't have the registry used, so when you want to use a package from one registry that is cached from another it gets the cached version from another registry instead of the version of the desired registry. |
Hi @Tobbe, thanks for taking the time to report this! From my understanding of the internals and the documentation
Here's the relevant bit in case you're interested into digging more 😊 cli/workspaces/libnpmexec/lib/cache-install-dir.js Lines 14 to 18 in 76afe15
With that in mind, since this is working as intended I'm going to close this issue. But feel free to open a new ones in case you find any other bug. In case you would like to propose a different behavior to Thanks again! |
`npx react-native init` [is not guaranteed](npm/cli#4108) to pull in `react-native@latest`. When the bootstrapping CLI is mismatched from the react-native version it tries to install, it may not work correctly. Currently, this means if you previously installed RN 0.70, you may end up using `react-native init` from RN 0.70, using CLI `9.2.1`, to bootstrap your React Native 0.71 app. This seems to lead to the CLI not correctly generating the template app. Most visibly, files like `_rbenv` are not converted to `.rbenv`. This seems like a CLI bug. `--version` exists to allow CLI to bootstrap different RN version, so it should support this sceanrio. But we can change the example to one that prevents users from hitting it.
`npx react-native init` [is not guaranteed](npm/cli#4108) to pull in `react-native@latest`. When the bootstrapping CLI is mismatched from the react-native version it tries to install, it may not work correctly. Currently, this means if you previously installed RN 0.70, you may end up using `react-native init` from RN 0.70, using CLI `9.2.1`, to bootstrap your React Native 0.71 app. This seems to lead to the CLI not correctly generating the template app. Most visibly, files like `_rbenv` are not converted to `.rbenv`. This seems like a CLI bug. `--version` exists to allow CLI to bootstrap different RN version, so it should support this sceanrio. But we can change the example to one that prevents users from hitting it.
`npx react-native init` [is not guaranteed](npm/cli#4108) to pull in `react-native@latest`. When the bootstrapping CLI is mismatched from the react-native version it tries to install, it may not work correctly. Currently, this means if you previously installed RN 0.70, you may end up using `react-native init` from RN 0.70, using CLI `9.2.1`, to bootstrap your React Native 0.71 app. This seems to lead to the CLI not correctly generating the template app. Most visibly, files like `_rbenv` are not converted to `.rbenv`. This seems like a CLI bug. `--version` exists to allow CLI to bootstrap different RN version, so it should support this sceanrio. But we can change the example to one that prevents users from hitting it.
I had the same problem, when I was at [@v1.0.1]; exec |
i think this use way, maybe a suitable way, we can choose version to use , eg. |
@ruyadorno and other maintainers: If it is indeed how npx is designed to work — in that npx will always run a cached version of a package if it exists, regardless of age, unless you specify I doubt that this behaviour would be obvious to most users, and is likely to create a whole range of bugs from people who run an There is currently nothing mentioned about this caching behaviour on the npx documentation page. I had to find this out from random StackOverflow users and go searching until I ended up in this thread. If npx documentation requests belong in a another repo, please point me in the right direction. |
This behavior of not necessarily using the latest version also makes |
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
npx is running an old version of a script
I've checked to make sure it's not installed (globally or locally)
This issue is very similar #2329 but it's closed. So either this problem has come back again, or it wasn't truly fixed in the first place.
Expected Behavior
As long as the given package is not installed, I expect npx to always use the latest version
Steps To Reproduce
It's always reproducible with the steps given above in "Current Behavior", but I don't yet know if it's reproducible with any package, or just @redwoodjs/codemods
Environment
The text was updated successfully, but these errors were encountered: