> ## Documentation Index
> Fetch the complete documentation index at: https://docs.root.io/llms.txt
> Use this file to discover all available pages before exploring further.

# yarn

> Configure Yarn (Classic and Berry) to use Root Library Catalog for secure JavaScript packages.

Root serves patched npm packages under the `@rootio/` scope. Use `resolutions` in `package.json` to route the original package to its Root-patched equivalent. Auth setup differs between Yarn 1 and Yarn 3+.

## Yarn 1 (Classic)

### Authentication

```bash theme={null}
npm config set registry https://pkg.root.io/npm/ --location=project &&
npm config set //pkg.root.io/npm/:_authToken YOUR_ROOT_TOKEN --location=project
```

### Update package.json

```bash theme={null}
yarn remove axios
```

```json theme={null}
{
  "resolutions": {
    "axios": "npm:@rootio/axios@1.6.0"
  }
}
```

### Install

```bash theme={null}
yarn install
```

***

## Yarn 3+ (Berry)

### Authentication

```bash theme={null}
yarn config set npmScopes.rootio.npmRegistryServer https://pkg.root.io/npm/ &&
yarn config set 'npmRegistries["//pkg.root.io/npm/"].npmAuthIdent' 'root:YOUR_ROOT_TOKEN'
```

### Update package.json

```bash theme={null}
yarn remove axios
```

```json theme={null}
{
  "resolutions": {
    "axios": "npm:@rootio/axios@1.6.0"
  }
}
```

### Install

```bash theme={null}
yarn install
```

***

## Troubleshooting

| Issue                       | Solution                                                          |
| --------------------------- | ----------------------------------------------------------------- |
| `401 Unauthorized` (Yarn 1) | Verify your token: `npm config get //pkg.root.io/npm/:_authToken` |
| `401 Unauthorized` (Yarn 3) | Check `npmAuthIdent` is set as `root:YOUR_TOKEN` (not base64)     |
| Resolutions not applying    | Confirm the package name in `resolutions` matches exactly         |
