1
votes

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.

1
DV for lack of research - Jota.Toledo
@Jota.Toledo thanks for your reply but you should read carefully the description before reply, look at the note. - codeon9
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
component was working without any problem , the problem i found with the directive - codeon9

1 Answers

1
votes

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"