Skip to content

Commit d6ef225

Browse files
docs: add npx prefix before react-native command (#2035)
* docs: add `npx` prefix to `react-native` * docs: add `@latest` to `init` command * test: update snapshosts
1 parent 0296d31 commit d6ef225

File tree

21 files changed

+58
-58
lines changed

21 files changed

+58
-58
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ labels: 'bug report'
66

77
## Environment
88

9-
<!-- Run `react-native info` in your terminal and paste its contents here. -->
9+
<!-- Run `npx react-native info` in your terminal and paste its contents here. -->
1010

1111
## Description
1212

1313
<!--
1414
Describe your issue in detail. Include screenshots if needed. If this is a regression, let us know.
1515
-->
1616

17-
1817
## Reproducible Demo
1918

2019
<!--

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ All work on React Native CLI happens directly on GitHub. Contributors send pull
1616
> Please make sure the version of React Native matches the one present in devDependencies of the CLI. Otherwise, you may get unexpected errors.
1717
1818
_Note: you must use the `--watchFolders` flag with the `start` command when testing the CLI with `yarn link` like this. Otherwise Metro can't find the symlinked folder and this may result in errors such as `ReferenceError: SHA-1 for file ... is not computed`. If you are experiencing this error while using Release configuration, please add `watchFolders: ["path/to/cloned/cli/"]` to your `metro.config.js` file._
19+
1920
### Setup
2021

2122
Because of a modular design of the CLI, we recommend developing using symbolic links to its packages. This way you can use it seamlessly in the tested project, as you'd use the locally installed CLI. Here's what you need to run in the terminal:
@@ -66,7 +67,7 @@ First make sure you have RN repo checked out and CLI repo checked out and built.
6667

6768
1. Check out `react-native` repo. Then update template in local `react-native/template/package.json`, replacing dependency version of `react-native` with the absolute path of the react native repo, for example: "react-native": "file:///Users/username/react-native" (you can find the absolute path using `pwd` command)
6869

69-
1. Go back up and create a new RN project: `node ./cli/packages/cli/build/bin.js init --template=file:///path/to/local/react-native RNTestProject`
70+
1. Go back up and create a new RN project: `node ./cli/packages/cli/build/bin.js init --template=file:///path/to/local/react-native/RNTestProject`
7071

7172
1. To work with android, update gradle config in the newly created project following the second part of [Christoph's instructions](https://gist.github.com/cpojer/38a91f90614f35769e88410e3a387b48)
7273

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ This monorepository contains tools and helpers for React Native projects in form
5757
Run the following command in your terminal prompt:
5858

5959
```sh
60-
npx react-native init MyApp
60+
npx react-native@latest init MyApp
6161
```
6262

6363
## Usage in an existing React Native project

docs/commands.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ React Native CLI comes with following commands:
2828
Usage (with `npx`):
2929

3030
```sh
31-
npx react-native init <projectName> [options]
31+
npx react-native@latest init <projectName> [options]
3232
```
3333

3434
Initialize a new React Native project named <projectName> in a directory of the same name. You can find out more use cases in [init docs](./init.md).
@@ -59,10 +59,10 @@ Uses a custom template. Accepts following template sources:
5959
Example:
6060

6161
```sh
62-
npx react-native init MyApp --template react-native-custom-template
63-
npx react-native init MyApp --template file:///Users/name/template-path
64-
npx react-native init MyApp --template file:///Users/name/template-name-1.0.0.tgz
65-
npx react-native init MyApp --template Esemesek/react-native-new-template
62+
npx react-native@latest init MyApp --template react-native-custom-template
63+
npx react-native@latest init MyApp --template file:///Users/name/template-path
64+
npx react-native@latest init MyApp --template file:///Users/name/template-name-1.0.0.tgz
65+
npx react-native@latest init MyApp --template Esemesek/react-native-new-template
6666
```
6767

6868
A template is any directory or npm package that contains a `template.config.js` file in the root with the following type:
@@ -112,7 +112,7 @@ Create project with custom package name for Android and bundle identifier for iO
112112
Usage:
113113

114114
```sh
115-
react-native upgrade
115+
npx react-native upgrade
116116
```
117117

118118
This command generates a relevant link to the [Upgrade Helper](https://react-native-community.github.io/upgrade-helper/) to help you upgrade manually.

docs/healthChecks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Health Check Plugins
22

3-
Plugins can be used to extend the health checks that `react-native doctor` runs. This can be used to add additional checks for out of tree platforms, or other checks that are specific to a community module.
3+
Plugins can be used to extend the health checks that `npx react-native doctor` runs. This can be used to add additional checks for out of tree platforms, or other checks that are specific to a community module.
44

55
See [`Plugins`](./plugins.md) for information about how plugins work.
66

docs/init.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@ There are couple of ways to initialize new React Native projects.
44

55
### For `[email protected]` or greater
66

7-
#### Using `npx` utility:
7+
#### Using `npx` utility
88

99
```sh
10-
npx react-native init ProjectName
10+
npx react-native@latest init ProjectName
1111
```
1212

1313
> Note: If you have both `yarn` and `npm` installed on your machine, React Native CLI will always try to use `yarn`, so even if you use `npx` utility, only `react-native` executable will be installed using `npm` and the rest of the work will be delegated to `yarn`. You can force usage of `npm` adding `--npm` flag to the command.
1414
1515
> Note: for Yarn users, `yarn dlx` command similar to `npx` will be featured in Yarn 2.0: <https://github.com/yarnpkg/berry/pull/40> so we’ll be able to use it in a similar fashion.
1616
17-
#### Installing `react-native` and invoking `init` command:
17+
#### Installing `react-native` and invoking `init` command
1818

1919
```sh
2020
yarn init && yarn add react-native && yarn react-native init ProjectName
2121
```
2222

23-
#### Initializing project with custom version of `react-native`:
23+
#### Initializing project with custom version of `react-native`
2424

2525
```sh
2626
# This will use the latest init command but will install react-native@VERSION and use its template
27-
npx react-native init ProjectName --version ${VERSION}
27+
npx react-native@latest init ProjectName --version ${VERSION}
2828

2929
# This will use init command from react-native@VERSION
3030
npx react-native@${VERSION} init ProjectName
@@ -47,7 +47,7 @@ For all available options, please check [Yarn documentation](https://classic.yar
4747

4848
```sh
4949
# This will initialize new project using template from `react-native-template-typescript` package
50-
npx react-native init ProjectName --template ${TEMPLATE_NAME}
50+
npx react-native@latest init ProjectName --template ${TEMPLATE_NAME}
5151

5252
# This will initialize new project using init command from react-native@VERSION but will use a custom template
5353
npx react-native@${VERSION} init ProjectName --template ${TEMPLATE_NAME}
@@ -56,7 +56,7 @@ npx react-native@${VERSION} init ProjectName --template ${TEMPLATE_NAME}
5656
You can force usage of `npm` if you have both `yarn` and `npm` installed on your machine:
5757

5858
```sh
59-
npx react-native init ProjectName --npm
59+
npx react-native@latest init ProjectName --npm
6060
```
6161

6262
### For older `react-native` versions
@@ -65,7 +65,7 @@ Using legacy `react-native-cli` package:
6565

6666
```sh
6767
yarn global add react-native-cli
68-
react-native init ProjectName
68+
npx react-native@latest init ProjectName
6969
```
7070

7171
> Note: It is not recommended, but you can also use legacy `react-native-cli` package to initialize projects using latest `react-native` versions.

docs/plugins.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Plugin is a JavaScript package that extends built-in React Native CLI features. It can provide an array of additional commands to run or platforms to target.
44

5-
For example, `react-native-windows` package is a plugin that provides `react-native run-windows` command and `windows` platform.
5+
For example, `react-native-windows` package is a plugin that provides `run-windows` command and `windows` platform.
66

77
Details of this particular integration as well as how to provide an additional platform for React Native were described in a [`dedicated section`](./platforms.md) about platforms.
88

@@ -21,13 +21,13 @@ module.exports = {
2121
};
2222
```
2323

24-
> Above is an example of a plugin that exports a command named `foo-command` that can be executed with `react-native foo-command` and logs "It worked" and exits.
24+
> Above is an example of a plugin that exports a command named `foo-command` that can be executed with `npx react-native foo-command` and logs "It worked" and exits.
2525
2626
At the startup, React Native CLI reads configuration from all dependencies listed in `package.json` and reduces them into a single configuration.
2727

2828
At the end, an array of commands concatenated from all plugins is passed on to the CLI to be loaded after built-in commands.
2929

30-
> See [`healthChecks`](./healthChecks.md) for information on how plugins can provide additional health checks for `react-native doctor`.
30+
> See [`healthChecks`](./healthChecks.md) for information on how plugins can provide additional health checks for `npx react-native doctor`.
3131
3232
## Command interface
3333

docs/projects.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ multiple `Podfile` files in your project.
8686

8787
#### project.ios.watchModeCommandParams
8888

89-
Array of strings that will be passed to the `react-native run-ios` command when running in watch mode.
89+
Array of strings that will be passed to the `npx react-native run-ios` command when running in watch mode.
9090

9191
#### project.ios.unstable_reactLegacyComponentNames
9292

@@ -122,7 +122,7 @@ See [`dependency.platforms.android.configuration`](dependencies.md#platformsandr
122122

123123
#### project.android.watchModeCommandParams
124124

125-
Array of strings that will be passed to the `react-native run-android` command when running in watch mode.
125+
Array of strings that will be passed to the `npx react-native run-android` command when running in watch mode.
126126

127127
#### project.android.unstable_reactLegacyComponentNames
128128

packages/cli-clean/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ yarn add @react-native-community/cli-clean
1515
Usage:
1616

1717
```sh
18-
react-native clean
18+
npx react-native clean
1919
```
2020

2121
Cleans caches. Commonly used to ensure build failures are not due to stale cache. By default, it will prompt which caches to purge, with Watchman and Metro already checked. To omit interactive prompt (e.g. in scripts), please use `--include` flag.

packages/cli-config/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ yarn add @react-native-community/cli-config
1515
Usage:
1616

1717
```sh
18-
react-native config
18+
npx react-native config
1919
```
2020

2121
Output project and dependencies configuration in JSON format to stdout. Used by [autolinking](./../../docs/autolinking.md).

0 commit comments

Comments
 (0)