1

To create Directive in Angular 4 cli from git

/Angular/projectName $ ng generate directive DirectiveName

should work

[note : DirectiveName is unique not match with component name or module name]

but I am getting Error

Error: More than one module matches. Use skip-import option to skip importing the component into the closest module. More than one module matches. Use skip-import option to skip importing the component into the closest module.

codeon9
  • 23
  • 4
  • Possible duplicate of [Error: More than one module matches. Use skip-import option to skip importing the component into the closest module](https://stackoverflow.com/questions/46174863/error-more-than-one-module-matches-use-skip-import-option-to-skip-importing-th) – Jota.Toledo Oct 31 '17 at 17:41
  • DV for lack of research – Jota.Toledo Oct 31 '17 at 17:43
  • @Jota.Toledo thanks for your reply but you should read carefully the description before reply, look at the note. – codeon9 Oct 31 '17 at 18:32
  • The note makes no difference, the error is pretty clear and if you had googled its message you would have found the solution – Jota.Toledo Oct 31 '17 at 19:22
  • component was working without any problem , the problem i found with the directive – codeon9 Nov 01 '17 at 17:55

1 Answers1

1

At this moment CLI got confused to on step to insert declarations inside a which module, because you have more than one module in your application. You could append skip-import flag at the end of command. But that will skip importing & declaring component inside module.

I'd recommend to specify the --module in command where your directive should get declared.

ng generate directive DirectiveName --module="your-module.module.ts"
Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299