ng g c c-name =>指定的模块不存在

时间:2018-10-01 20:27:48

标签: angular angular-cli angular-cli-v6

我当前的目录

/src/app

app.module.ts目录

/src/app/app.module.ts

此目录中需要一个新组件

catalog/single/configurator/[new component here]

尝试添加组件#1

ng g c catalog/single/configurator/details-popout --module AppModule

  

指定的模块不存在

尝试添加组件#2

ng g c catalog/single/configurator/details-popout --module /app.module

  

无效的规则结果:Function()。

尝试添加组件#3

ng g c catalog/single/configurator/details-popout --module app

  

无效的规则结果:Function()。


问题

如何使用Angular CLI添加组件details-popout

Env

Angular CLI: 6.0.8
Node: 9.2.0
OS: darwin x64
Angular: 6.1.7
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.8
@angular-devkit/build-angular     0.6.8
@angular-devkit/build-optimizer   0.6.8
@angular-devkit/core              0.6.8
@angular-devkit/schematics        0.7.5
@angular/cli                      6.0.8
@angular/fire                     5.0.0
@angular/pwa                      0.6.8
@ngtools/webpack                  6.0.8
@schematics/angular               0.7.5
@schematics/update                0.6.8
rxjs                              6.3.2
typescript                        2.7.2
webpack                           4.8.3

1 个答案:

答案 0 :(得分:1)

ng g c catalog/single/configurator/details-popout --module app.module.ts

  

允许指定声明模块的文件名(例如   app.module.ts

Doc is here

真正的问题是:

确保您的@angular/cli软件包已更新为最新的运行版本:

npm install -g @angular/cli