-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
feat(cli) check and warn if npx react-native version is using an old cached version #37510
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
facebook-github-bot
added
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
p: Facebook
Partner: Facebook
Partner
labels
May 22, 2023
blakef
changed the title
feat(cli) check and warn if react-native version is old
feat(cli) check and warn if May 22, 2023
npx react-native
version is old
blakef
changed the title
feat(cli) check and warn if
feat(cli) check and warn if npx react-native version is using an old cached version
May 22, 2023
npx react-native
version is oldnpx react-native commands can be cached in unexpected ways. Adding a warning to users if this is the case to encourage them to use npx react-native@latest (per the docs). [General][Added] - Log a warning if npx react-native uses old cached version
@blakef has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Base commit: 92c7219 |
facebook-github-bot
pushed a commit
that referenced
this pull request
Jan 10, 2024
Summary: Dependency on `chalk` was introduced in #37510, but was never declared. In pnpm setups, the CLI fails to run because of this. This needs to be picked to 0.73. ## Changelog: [GENERAL] [FIXED] - Declare missing dependency `chalk` Pull Request resolved: #42235 Test Plan: n/a Reviewed By: huntie Differential Revision: D52660337 Pulled By: cortinico fbshipit-source-id: 1cd45fcff72045c127773566a27103f1b38262b3
gokul1099
pushed a commit
to gokul1099/react-native-visionos
that referenced
this pull request
Jan 17, 2024
Summary: Dependency on `chalk` was introduced in facebook#37510, but was never declared. In pnpm setups, the CLI fails to run because of this. This needs to be picked to 0.73. ## Changelog: [GENERAL] [FIXED] - Declare missing dependency `chalk` Pull Request resolved: facebook#42235 Test Plan: n/a Reviewed By: huntie Differential Revision: D52660337 Pulled By: cortinico fbshipit-source-id: 1cd45fcff72045c127773566a27103f1b38262b3
blakef
pushed a commit
that referenced
this pull request
Jan 25, 2024
Summary: Dependency on `chalk` was introduced in #37510, but was never declared. In pnpm setups, the CLI fails to run because of this. This needs to be picked to 0.73. [GENERAL] [FIXED] - Declare missing dependency `chalk` Pull Request resolved: #42235 Test Plan: n/a Reviewed By: huntie Differential Revision: D52660337 Pulled By: cortinico fbshipit-source-id: 1cd45fcff72045c127773566a27103f1b38262b3
facebook-github-bot
pushed a commit
that referenced
this pull request
May 23, 2024
…44644) Summary: In #37510, a check was introduced to check if user is using `latest` version of `npx`, but right now it checks for every command executed, but it should only ensure that `latest` is included when creating a new project. In this Pull Request I've added a condition to only warn if `init` was fired. ## Changelog: [GENERAL] [FIXED] - Warn only in `init` command when CLI uses cached `npx` version Pull Request resolved: #44644 Test Plan: Warning about using `latest` version CLI should only be presented when running `init` command. Reviewed By: arushikesarwani94 Differential Revision: D57681864 Pulled By: blakef fbshipit-source-id: 5c81b9a08141396efcd24539b2560cea16028dd9
cipolleschi
pushed a commit
that referenced
this pull request
Jun 3, 2024
…44644) Summary: In #37510, a check was introduced to check if user is using `latest` version of `npx`, but right now it checks for every command executed, but it should only ensure that `latest` is included when creating a new project. In this Pull Request I've added a condition to only warn if `init` was fired. [GENERAL] [FIXED] - Warn only in `init` command when CLI uses cached `npx` version Pull Request resolved: #44644 Test Plan: Warning about using `latest` version CLI should only be presented when running `init` command. Reviewed By: arushikesarwani94 Differential Revision: D57681864 Pulled By: blakef fbshipit-source-id: 5c81b9a08141396efcd24539b2560cea16028dd9
kosmydel
pushed a commit
to kosmydel/react-native
that referenced
this pull request
Jun 11, 2024
…acebook#44644) Summary: In facebook#37510, a check was introduced to check if user is using `latest` version of `npx`, but right now it checks for every command executed, but it should only ensure that `latest` is included when creating a new project. In this Pull Request I've added a condition to only warn if `init` was fired. ## Changelog: [GENERAL] [FIXED] - Warn only in `init` command when CLI uses cached `npx` version Pull Request resolved: facebook#44644 Test Plan: Warning about using `latest` version CLI should only be presented when running `init` command. Reviewed By: arushikesarwani94 Differential Revision: D57681864 Pulled By: blakef fbshipit-source-id: 5c81b9a08141396efcd24539b2560cea16028dd9
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
💻CLI
Merged
This PR has been merged.
p: Facebook
Partner: Facebook
Partner
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Currently npx has a variety of caching strategies to avoid having to pull a version of the package from a registry. These are often unexpected to our users, who may fall behind. After looking at a variety of fancy approaches to dealing with this (the high end of which was intelligently forking npx to run
npx react-native@latest <args>
, the best possible tradeoff for time and simplicity was to warn the user when they weren't running the latest release:Problem Details
On my laptop when you run
npx <package> <arguments>
this it eventually calls libnpmexec, which applies this lookup algorithm forpackage@version
:~/project/node_modules/<package>
)?. Importantly it will walk all the way down to/
looking fornode_modules/<package>
./Users/blakef/.nvm/versions/node/v17.9.0/lib/node_modules
)?~/.npm/_npx
)?~/.npm/_npx/<hash>/
At this point you'll have a cached copy, which then has its bin script run with the arguments you originally provided.
How this works against React-Native users
Users can get their development environment into a persistent pickle with a bunch of unintended side-effects of npx / npm exec’s caching model:
npx react-native
, since it’ll default to the version of react-native in a node package's folder. This works well for us in a React Native project, but not when initializing a project outside of a package folder.node_modules/react-native
installation anywhere in the directory hierarchy it’ll be used. For example if I runnpx react-native init Foobar
in/home/blakef/src/example
, npx will look for versions of react-native like this before searching globals or the npx cache:nvm just makes things harder if your user switches between versions of node it can be hard to determine if they're affected by a globally installed version. Examples include having a
.nvmrc
file in the directory they run the command which transparently switches node version (and globals location).Changelog:
[General][Added] - Log a warning if npx react-native uses old cached version
Test Plan:
Ran this directly from the project, defining the
npm_lifecycle_event=npx
to mock directly running usingnpx
.