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

# Attaching debuggers to Braintrust eval CLI

export const plans_0 = "Any"

export const deployments_0 = "Any"

export const data_plane_version_0 = undefined

export const use_case_0 = "Use case - eval CLI with packages using ESM imports like import.meta.url"

<Note>
  **Applies to:**

  * Plan - {plans_0}
  * Deployment - {deployments_0}
  * {data_plane_version_0}
  * {use_case_0}
</Note>

## 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.
