> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/usebruno/bruno/llms.txt
> Use this file to discover all available pages before exploring further.

# Installing Bruno CLI

> Install the Bruno CLI tool to run your API collections from the command line

# Installing Bruno CLI

The Bruno CLI is distributed as an npm package (`@usebruno/cli`) and can be installed globally or as a project dependency.

## Global Installation

Install Bruno CLI globally to use it across all your projects:

<CodeGroup>
  ```bash npm theme={null}
  npm install -g @usebruno/cli
  ```

  ```bash yarn theme={null}
  yarn global add @usebruno/cli
  ```

  ```bash pnpm theme={null}
  pnpm add -g @usebruno/cli
  ```
</CodeGroup>

After installation, verify it's working:

```bash theme={null}
bru --version
```

## Project Installation

Install as a development dependency in your project:

<CodeGroup>
  ```bash npm theme={null}
  npm install --save-dev @usebruno/cli
  ```

  ```bash yarn theme={null}
  yarn add --dev @usebruno/cli
  ```

  ```bash pnpm theme={null}
  pnpm add -D @usebruno/cli
  ```
</CodeGroup>

Then add scripts to your `package.json`:

```json package.json theme={null}
{
  "scripts": {
    "test:api": "bru run",
    "test:api:local": "bru run --env local",
    "test:api:production": "bru run --env production --reporter-junit results.xml"
  }
}
```

Run the tests:

```bash theme={null}
npm run test:api
```

## Version Information

Check the installed version:

```bash theme={null}
bru --version
```

Get help and see available commands:

```bash theme={null}
bru --help
```

## System Requirements

<Note>
  **Node.js version:** Bruno CLI requires Node.js 14 or higher.
</Note>

* **Node.js:** v14.0.0 or higher
* **npm:** v6.0.0 or higher (or equivalent yarn/pnpm version)
* **Operating Systems:** Linux, macOS, Windows

## CI/CD Environment Installation

For CI/CD pipelines, install as part of your build process:

<CodeGroup>
  ```yaml GitHub Actions theme={null}
  name: API Tests

  on: [push, pull_request]

  jobs:
    test:
      runs-on: ubuntu-latest
      steps:
        - uses: actions/checkout@v3
        - uses: actions/setup-node@v3
          with:
            node-version: '18'
        - name: Install Bruno CLI
          run: npm install -g @usebruno/cli
        - name: Run API Tests
          run: bru run --reporter-junit results.xml
          working-directory: ./api-tests
        - name: Publish Test Results
          uses: EnricoMi/publish-unit-test-result-action@v2
          if: always()
          with:
            files: ./api-tests/results.xml
  ```

  ```yaml GitLab CI theme={null}
  api-tests:
    image: node:18
    script:
      - npm install -g @usebruno/cli
      - cd api-tests
      - bru run --reporter-junit results.xml
    artifacts:
      when: always
      reports:
        junit: api-tests/results.xml
  ```

  ```yaml CircleCI theme={null}
  version: 2.1

  jobs:
    api-test:
      docker:
        - image: cimg/node:18.0
      steps:
        - checkout
        - run:
            name: Install Bruno CLI
            command: npm install -g @usebruno/cli
        - run:
            name: Run API Tests
            command: bru run --reporter-junit results.xml
            working_directory: api-tests
        - store_test_results:
            path: api-tests/results.xml
  ```
</CodeGroup>

## Docker Installation

Create a Dockerfile for running Bruno CLI tests:

```dockerfile Dockerfile theme={null}
FROM node:18-alpine

# Install Bruno CLI
RUN npm install -g @usebruno/cli

# Copy your collection
WORKDIR /app
COPY ./api-collection /app

# Run tests
CMD ["bru", "run", "--reporter-junit", "results.xml"]
```

Build and run:

```bash theme={null}
docker build -t bruno-tests .
docker run --rm -v $(pwd)/results:/app/results bruno-tests
```

## Updating Bruno CLI

Keep your CLI up to date with the latest features:

<CodeGroup>
  ```bash npm (global) theme={null}
  npm update -g @usebruno/cli
  ```

  ```bash npm (project) theme={null}
  npm update @usebruno/cli
  ```

  ```bash yarn theme={null}
  yarn upgrade @usebruno/cli
  ```

  ```bash pnpm theme={null}
  pnpm update @usebruno/cli
  ```
</CodeGroup>

## Troubleshooting

### Command Not Found

If `bru` is not recognized after installation:

1. **Check npm global path:**
   ```bash theme={null}
   npm config get prefix
   ```

2. **Add to PATH:** Ensure the npm global bin directory is in your PATH:
   ```bash theme={null}
   export PATH="$(npm config get prefix)/bin:$PATH"
   ```

3. **Use npx:** As an alternative, run without installing globally:
   ```bash theme={null}
   npx @usebruno/cli run
   ```

### Permission Errors

On Linux/macOS, if you get permission errors during global installation:

```bash theme={null}
sudo npm install -g @usebruno/cli
```

Or configure npm to use a different directory (recommended):

```bash theme={null}
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Running Tests" icon="play" href="/cli/running-tests">
    Learn how to run your API tests with the CLI
  </Card>

  <Card title="CLI Options" icon="sliders" href="/cli/options">
    Explore all available command-line options
  </Card>
</CardGroup>
