Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsAngular NG0301 means a template requests a directive by an export name that Angular cannot find in that template’s context. Find the exact name in the error, locate the template reference using it, then check that the directive is available there and exposes that name. For the common ngForm case, Angular’s documented fix is to import FormsModule in the relevant NgModule.
What does NG0301 mean?
A template can assign a name to a directive instance through a template reference, for example #form="ngForm". The name in quotation marks is an export name: the directive makes it available through its exportAs metadata. NG0301 means Angular cannot find a directive with the requested export name in that template’s context. It does not, by itself, diagnose a missing npm package.
Angular’s NG0301 error page describes the issue and gives ngForm as an example. The required import depends on the directive and library that provide the export; FormsModule is not a universal fix.
How to find and fix the missing export
- Read the full error. Note the exact export token Angular names, such as
ngForm. Start with that name rather than installing or updating packages indiscriminately. - Find where the template requests it. Search the relevant templates for the token, often in a reference such as
#form="ngForm". - Identify the directive that should provide it. Check which Angular directive or library is expected to expose that name.
- Check the imports for the template’s compilation context. Make sure the dependency providing the directive is imported where that template is compiled. For
ngForm, Angular’s documented example is to addFormsModuleto the relevant NgModule’simportslist. - Check custom directive metadata. If the directive is yours, inspect its
@Directivemetadata and confirm itsexportAsvalue matches the name in the template. The Angular Directive API reference documentsexportAs. - Restart the development server if needed. Angular notes that a restart may be necessary after adding an import if the error persists.
Is NG0301 the same as NG8003?
No. NG0301 is reported at runtime; NG8003, “Missing Reference Target,” is the compiler-time equivalent. Angular lists a missing import and a directive that does not provide the requested exportAs name among common causes of NG8003. If the error appears during compilation, follow the same steps: identify the referenced export, find the directive meant to provide it, and check its metadata and imports. See Angular’s NG8003 error page.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Quick Recap
Rank #4
Rank #3
Rank #2
#1 Best Overall
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.




