angular - 找不到 NgModule。使用 skip-import 选项跳过 NgModule 中的导入

标签 angular nrwl

当我使用 CLI 创建新组件时,我在这篇文章的主题中遇到错误:ng g c my-component --project=my-project(没有创建组件)

我看过其他帖子有相同的错误消息,但没有一个帖子还包括 Nrwl/Nx,我认为这与它有某种关系。项目从 Ng4 开始,并升级到 Ng6。

环境:

  • Angular CLI:6.0.8
  • 节点:8.9.4
  • 操作系统:win32 x64
  • Angular :6.0.6
  • @angular-devkit/架构师 0.6.8
  • @angular-devkit/build-angular 0.6.8
  • @angular-devkit/build-optimizer 0.6.8
  • @angular-devkit/核心 0.6.8
  • @angular-devkit/schematics 0.6.8
  • @angular/cdk 6.3.1
  • @angular/cli 6.0.8
  • @angular/material 6.3.1
  • @ngtools/webpack 6.0.8
  • @schematics/angular 0.6.1
  • @schematics/更新 0.6.8
  • rxjs 6.2.1
  • typescript 2.7.2
  • 网页包 4.8.3
  • nrwl/nx 6.1.0

更新#1

我尝试完全删除 --project 标志(所以只是 ng g c my-component),但仍然遇到同样的问题。还不确定这意味着什么。

最佳答案

快速修复

1) 更改 cmd/terminal 中的当前目录src/app

cd src/app (linux)

cd .\src\app\ (windows)

2) 立即运行命令

ng g c myComponent

关于angular - 找不到 NgModule。使用 skip-import 选项跳过 NgModule 中的导入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51200919/

相关文章:

node.js - 无法在 centos 7 上安装 Angular cli

angular - 从组件获取 ViewContainerRef

node.js - Angular,未找到图像(GET 404),但运行 ng build 后显示图像

javascript - 如何找到nrwl模块 "Cannot find module"的原因?

node.js - 在 Nx 工作区中运行 NestJS 构建工件时出错

node.js - 没有服务器的 Angular 2 应用程序?

html - Bootstrap 类未按预期工作

angular - 运行 "Invalid options provided"时获取 "yarn affected-depgraph"

angular - 如何使 Angular 11 i18n 在 NRWL NX workspace.json 中工作?

angular - 禁止在 Nrwl Nx 中的同一库中导入桶文件