Search code examples
angularangular8angular-http-interceptors

angular 8: "Schematic "interceptor" not found in collection" error while generating interceptor in Angular cli


I am executing command

ng g interceptor error

where error is the name of interceptor

but facing the issue as below:

An unhandled exception occurred: Schematic "interceptor" not found in collection "@schematics/angular".

Do we have to install any package first ?


Solution

  • Looks like schematic support for generating interceptors was added in CLI 9.0.0

    So, you can either upgrade to Angular 9, or write your own custom schematic, though in the short-term, if you can't / don't want to upgrade to Angular 9, it's probably easier to just write your interceptor yourself instead of generating it.