Skip to content

Commit dc26492

Browse files
committed
docs: document steps to avoid the workspace warning for yarn 1
1 parent 91059d9 commit dc26492

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

README.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,12 @@ If your library depends on another react-native library containing native code,
250250

251251
- **Add the native library to `peerDependencies`**
252252

253-
This means that the user will need to install the native library and add it to their `package.json`. It makes sure that:
253+
This means that the consumer of the library will need to install the native library and add it to the `dependencies` section of their `package.json`. It makes sure that:
254254

255255
- There are no version conflicts if another package also happens to use the same library, or if the user wants to use the library in their app. While there can be multiple versions of a JavaScript-only library, there can only be one version of a native library - so avoiding version conflicts is important.
256256
- The package manager installs it in correct location so that autolinking can work properly.
257257

258-
Don't add the native library to `dependencies`, otherwise it may cause issues for the user even if it seems to work.
258+
Don't add the native library to `dependencies` of your library, otherwise it may cause issues for the user even if it seems to work.
259259

260260
- **Add the native library to `devDependencies`**
261261

@@ -339,6 +339,34 @@ For more accurate testing, we recommend following approaches:
339339

340340
You can find installation and usage instructions in the [Verdaccio documentation](https://verdaccio.org/docs/en/installation).
341341

342+
### Users get a warning when they install my library
343+
344+
If users are using Yarn 1, they may get a warning when installing your library:
345+
346+
```sh
347+
warning Workspaces can only be enabled in private projects.
348+
```
349+
350+
This is because the library is configured as a Yarn workspace, and there is a [bug in Yarn 1](https://github.com/yarnpkg/yarn/issues/8580) which causes this warning to be shown for third-party packages. It has no impact for the consumers of the library and the warning can be ignored. If consumers would like to get rid of the warning, there are 2 options:
351+
352+
1. **Disable workspaces**
353+
354+
If the consumer doesn't use Yarn workspaces, they can disable it by adding the following to the `.yarnrc` file in the root of their project:
355+
356+
```rc
357+
workspaces-experimental false
358+
```
359+
360+
2. **Upgrade to Yarn 3**
361+
362+
Yarn 1 is no longer maintained, so it's recommended to upgrade to Yarn 3. Yarn 3 works with React Native projects with the `node-modules` linker. To upgrade, consumers can follow the [official upgrade guide](https://yarnpkg.com/migration/guide).
363+
364+
It's also necessary to use `node-modules` linker. To use it, consumers can add the following to the `.yarnrc.yml` file in the root of their project:
365+
366+
```yml
367+
nodeLinker: node-modules
368+
```
369+
342370
## Development workflow
343371
344372
This project uses a monorepo using `yarn`. To setup the project, run `yarn` in the root directory to install the required dependencies.

0 commit comments

Comments
 (0)