# Angular: NG0301: Export of name 'x' not found! (template variable #x="exportAs")

**Code:** `NG0301` · **Category:** Angular · **Seen on:** Angular, TypeScript

A template variable asks for a directive by `exportAs` name, but no directive with that export is on the element at runtime.

## Meaning

Same cause as NG8003 but raised at runtime (JIT or tests). The directive's module is not loaded or does not apply to this element. Check the `exportAs` name and the imports of the component under test.

## Common causes

- Module that provides the directive is not imported (often in a unit test's `TestBed`)
- Wrong `exportAs` string
- Directive selector does not match the element
- Lazy-loaded module not loaded yet
- Standalone directive missing from `imports`

## Quick fix

1. Import the directive or module in the component and in the TestBed
2. Verify the exportAs name in the docs
3. Check the element matches the directive selector

## Detailed fix by platform

### Angular

1. `TestBed.configureTestingModule({ imports: [FormsModule, MatMenuModule] })` for components that use exportAs references

## How to diagnose

1. **Name** — Which exportAs?
2. **Imports** — In the component and the test?
3. **Element** — Selector matches?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/angular/ng0301-export-of-name-not-found)
