Skip to content

Commit 77aaacb

Browse files
committed
docs: improve documentation on testing packages locally
1 parent 3bad82d commit 77aaacb

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

README.md

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ To configure your project manually, follow these steps:
5757

5858
1. First, install `react-native-builder-bob` in your project. Open a Terminal in your project, and run:
5959

60-
```sh
61-
yarn add --dev react-native-builder-bob
62-
```
60+
```sh
61+
yarn add --dev react-native-builder-bob
62+
```
6363

6464
1. In your `package.json`, specify the targets to build for:
6565

@@ -300,9 +300,37 @@ There are 2 parts to this process.
300300

301301
You may have come across the `yarn link` and `npm link` commands to test libraries locally. These commands work great for simple packages without build process, but they have different behavior from how a published package works.
302302

303-
For more accurate testing, you could create a tarball using `npm pack` and install it instead, but it also has [some issues](https://github.com/yarnpkg/yarn/issues/6811).
303+
For more accurate testing, we recommend following approaches:
304+
305+
1. **Local tarball with `npm`**
306+
307+
First, temporarily change the version in `package.json` to something like `0.0.0-local.0`. This version number needs to be updated to something different every time you do this to avoid [stale content](https://github.com/yarnpkg/yarn/issues/6811).
308+
309+
Run the following command inside your library's root:
310+
311+
```sh
312+
npm pack
313+
```
314+
315+
This will generate a file like `your-library-name-0.0.0-local.0.tgz` in the root of the project.
316+
317+
Then, you can install the tarball in your app:
318+
319+
```sh
320+
yarn add ../path/to/your-library-name-0.0.0-local.0.tgz
321+
```
322+
323+
Or if you use `npm`:
324+
325+
```sh
326+
npm install ../path/to/your-library-name-0.0.0-local.0.tgz
327+
```
328+
329+
2. **Verdaccio**
330+
331+
[Verdaccio](https://verdaccio.org/) is a lightweight private npm registry that can be used to test packages locally. The advantage of using Verdaccio is that it allows to test the complete workflow of publishing and installing a package without actually publishing it to a remote registry.
304332

305-
The most reliable way is to use [Verdaccio](https://verdaccio.org/) to publish the library to a local server and install it.
333+
You can find installation and usage instructions in the [Verdaccio documentation](https://verdaccio.org/docs/en/installation).
306334

307335
## Development workflow
308336

0 commit comments

Comments
 (0)