node.js - Angular CLI 创建组件抛出错误;找不到 NgModule
问题描述
我正在开发 Angular 6 应用程序并尝试使用 CLI 使用“ng gc myComponent”创建新组件,但出现错误
我的所有组件都在 app / 的模块文件夹下(根级组件)
错误
Could not find an NgModule. Use the skip-import option to skip importing in NgModule.
警告信息
Your global Angular CLI version (7.2.2) is greater than your local
version (6.2.9). The local Angular CLI version is used.
To disable this warning use "ng config -g cli.warnings.versionMismatch
false".
Two or more projects are using identical roots. Unable to determine
project using current working directory. Using default workspace project
instead.
当我运行 ng --version 时,我得到以下应用程序版本
Angular CLI: 6.2.9
Node: 8.9.3
OS: win32 x64
Angular: 5.2.11
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
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.8.9
@angular/cli 6.2.9
@ngtools/webpack 6.0.8
@schematics/angular 0.8.9
@schematics/update 0.8.9
rxjs 5.5.12
typescript 2.5.3
webpack 4.8.3
解决方案
确保您的应用程序模块位于生成组件的文件夹中。这为我解决了。
推荐阅读
- python - 如何将 keras 预训练模型提供给计算图?
- python - 如果为空列表,则填充变量
- html - 有什么用?
- node.js - 永远的 Node.js 脚本在循环中挂起
- c# - 调用 Facebook/Google+ 时未点击 ExternalLogin
- git - 在 macOS 上启动 gitk 会出现错误 application is not running
- reactjs - 即使包装在条件中,ComponentDidUpdate 也会导致无限渲染
- jupyter - JupyterLab:如何自定义 bash 终端?
- ios - Different cell depending on the cell text
- python - 如何将输入的开头移动到and?