多个模块匹配。使用跳过导入选项可将组件跳过导入到最近的模块中

时间:2018-09-17 18:06:03

标签: angular

在以前的版本中,我刚刚能够生成一个像这样的新组件...

ng g c modules/update-tables/containers/users-container

错误:多个模块匹配。使用skip-import选项可以跳过将组件导入最接近的模块的过程。

然后我尝试...

ng g c containers/users-container --module=update-tables

错误:指定的模块不存在

然后我尝试...

ng g c containers/users-container --module UpdateTablesModule

错误:指定的模块不存在

enter image description here

2 个答案:

答案 0 :(得分:1)

您应从*.module.ts文件夹中指定/app文件的相对路径:

ng g c containers/users-container ./modules/update-tables/update-tables/update-tables.module.ts

您还可以省略后缀.module.ts

ng g c containers/users-container ./modules/update-tables/update-tables/update-tables

它甚至可以在没有模块名称的情况下运行,然后它将使用给定文件夹中的第一个,因此最好指定它:

ng g c containers/users-container ./modules/update-tables/update-tables

答案 1 :(得分:0)

我以前曾经遇到过这个问题。没有什么可以阻止您自己创建模块。 L查看任何现有的以查看模式,例如包括@NgModule和所有模式。对于该文件,创建一个名为users-container.module.ts的文件。然后将其自己添加到app.module.ts(或您需要在其中包含模块的任何位置)的imports部分中。