## TL;DR

Run the build, read the underlying error inside the imported file, then upgrade the offending library to a version built for your Angular major. NG6002 means the Angular compiler found errors in something you imported, and after an upgrade that is usually a library still shipped in the old compilation format. Matching the library to your Angular version clears it.

```text
error NG6002: This import contains errors, which may affect components without an explicit ngModule.
```

## Steps

1. Run `ng build` (not just serve) and scroll to the first NG6002. Note the file it names.
   Expected: you can tell whether the flagged file is yours or a library file.

2. If it is a library: check its changelog or readme for supported Angular versions, and run `npm ls @angular/core` to confirm a single copy.
   Expected: you find the library predates your Angular major, or two Angular copies in the tree.

3. Upgrade the library to the release matching your Angular major. Delete node_modules and the lockfile, then reinstall.
   Expected: `npm ls @angular/core` shows one version matching your Angular.

4. If the flagged file is your own (e.g. a barrel re-export), fix the underlying TypeScript error the compiler reports just above the NG6002 line.
   Expected: the root error is gone, so the import error goes with it.

5. Rebuild with `ng build`.
   Expected: the build succeeds with no NG6002.

## Use this when

- NG6002 appears right after an Angular major upgrade
- The error points into node_modules or a shared import rather than new code you wrote
- Multiple copies of @angular packages show up in the tree
- A library worked before the upgrade and nothing else changed

## Not for this skill when

- NG6002 is caused by a plain TypeScript syntax error in your own new code (fix the syntax)
- The error is about an import that cannot be resolved at all (different error code, different fix)
- You are on Angular 13+ with a View Engine-only library and no upgrade exists (that needs replacing the library, not this checklist)

## Variant phrasings

- angular NG6002 after upgrade
- This import contains errors ng build
- NG6002 library not compatible with angular version
- angular upgrade build fails on library import

## Why it happens

The Angular compiler type-checks the whole import graph of your app. When a library was compiled with an older Angular (pre-Ivy format, or an older Ivy metadata version), the new compiler cannot read it cleanly and reports the import as erroneous. Your code did not change; the compiler got stricter and the library got stale.

## Edge cases

- Two copies of @angular/core (app plus a linked library) produce phantom NG6002s. Dedupe first.
- tsconfig `paths` mappings can shadow a library with a stale local copy. Check them.
- Some libraries need specific module settings; check their install notes for your Angular major.
- If no compatible library release exists, the path is patching or replacing the library, not disabling the compiler checks.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_8YLYpgUuVT63l3JlumENzA
