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

# Attaching debuggers to Braintrust eval CLI

> [!NOTE]
>
> **Applies to:**
>
> * Plan - Any
> * Deployment - Any
> *
> * Use case - eval CLI with packages using ESM imports like import.meta.url

## Summary

**Error:** The Braintrust eval CLI fails with "import.meta.url is undefined" errors when evaluating packages that use ESM imports.

**Cause:** The CLI bundles packages during evaluation, losing ESM module context and causing import.meta.url to be undefined.

**Solution:** Use the `--external-packages` flag to prevent bundling of packages that require ESM context.

## Resolution Steps

### Step 1: Identify packages using ESM imports

Look for packages in your evaluation code that use `import.meta.url` or other ESM-specific features.

### Step 2: Add external packages flag

Use the `--external-packages` flag to mark these packages as external dependencies:

```text theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
braintrust eval eval.ts --external-packages @mastra/core,@mastra/observability

```

### Step 3: Test the evaluation

Run your evaluation again to confirm the error is resolved. The packages will now be loaded directly from `node_modules` with proper ESM context.

## Troubleshooting

### Multiple packages need external flag

Separate package names with commas without spaces:

```text theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
braintrust eval eval.ts --external-packages package1,package2,package3

```

### Still getting bundling errors

If you continue to see import.meta.url errors, check for additional packages in your dependency tree that use ESM imports and add them to the external packages list.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.