I have an Angular 4
project which at first I was able to use the ng generate component
command but since I have implemented Routing
the command no longer works as I get the following 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.
I'm not too sure if its the Routing
that is causing this but that's all I can seem to put my finger on and I need to get it fixed
The error speaks for itself, as you have at least two modules in your project. You need to use the skip-import flag because Angular is unable to decide for what module it should be imported. After you added the skip-import flag, the error will be gone. But you will have to manually import the component into the module you wish to utilize it in.
Like this:
ng generate component newComponent --skip-import
尝试在模块文件夹中运行ng g component ComponentName
。
It is working for me using VS 2017 on Windows 10 with @angular/cli (6.0.8):
ng gc components/name-component ---module ../app/app.shared.module.ts
And run this command from ...\\ClientApp\\app
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.