[Solved] An unhandled exception occurred:catch clause variable is not an Error instance, ng g c my-component AngularJs CLI error

Angular Mohit Mozumder

Problem:

While I am trying to creat component using ng g c my-component got the following error-

An unhandled exception occurred: catch clause variable is not an Error instance
AssertionError [ERR_ASSERTION]: catch clause variable is not an Error instance at assertIsError

I update angular cli but nothing changed.


Solution 1:

To solve this issue run this command:
ng g c modules/bla/component/example --skip-import 

It will create a new component with the name "example" in the folder modules/bla/component and it will also skip all the imports in the closest module.

Note: Add the component in the declations array in the linked module file.


Solution 2:

 If solution 1 is not working you can try by specifying the module in the ng g c... like this:
ng g c my-component --module=app.module


Thank you for reading the article. If you face any further problem feel to contact us.