找不到NgModule.使用skip-import选项跳过在NgModule中的导入 [英] Could not find an NgModule. Use the skip-import option to skip importing in NgModule

查看:658
本文介绍了找不到NgModule.使用skip-import选项跳过在NgModule中的导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用CLI创建新组件时,出现此主题错误:ng g c my-component --project=my-project(未创建任何组件)

I get the error in the subject of this post when I use the CLI to create a new component: ng g c my-component --project=my-project (No component is created)

我看过其他帖子,它们具有相同的错误消息,但是它们都没有包含Nrwl/Nx,我认为这与某种原因有关.该项目从Ng4开始,并已升级到Ng6.

I've seen other posts with the same error message, but none of them also include Nrwl/Nx, which I believe is somehow involved. Project started as Ng4 and was upgraded to Ng6.

有什么想法我可以解决这个问题吗?

Any ideas how I can fix this?

谢谢.

TTE

环境:

  • Angular CLI:6.0.8
  • 节点:8.9.4
  • 操作系统:win32 x64
  • 角度:6.0.6
  • @ 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.6.8
  • @ angular/cdk 6.3.1
  • @ angular/cli 6.0.8
  • @角度/材质6.3.1
  • @ ngtools/webpack 6.0.8
  • @ schematics/角度0.6.1
  • @ schematics/更新0.6.8
  • rxjs 6.2.1
  • 打字稿2.7.2
  • webpack 4.8.3
  • nrwl/nx 6.1.0
  • Angular CLI: 6.0.8
  • Node: 8.9.4
  • OS: win32 x64
  • Angular: 6.0.6
  • @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.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/update 0.6.8
  • rxjs 6.2.1
  • typescript 2.7.2
  • webpack 4.8.3
  • nrwl/nx 6.1.0

更新#1

我尝试完全删除--project标志(因此只是ng g c my-component),仍然遇到相同的问题.还不知道那是什么意思.

I tried dropping the --project flag entirely ( so just ng g c my-component) and still get the same problem. Not sure what that means, yet.

推荐答案

我最终完全删除了node_modules,清理了纱线缓存,然后运行yarn重新安装所有软件包.我还编辑了angular.json文件,以便所有应用程序和库的路径都像这样:

I ended up totally deleting node_modules, clearing out the yarn cache and then running yarn to reinstall all packages. I also edited my angular.json file so that my pathing looked like this for all applications and libraries:

"root": "libs/my-lib",
"sourceRoot": "libs/my-lib/src"

我不确定哪个解决了问题,但现在一切似乎都还可以.至少眼前的问题消失了.

I'm not sure which of those fixed the problem, but all appears to be OK now. At least the immediate problem went away.

希望这对其他人有帮助.

Hopefully this helps someone else.

TTE

这篇关于找不到NgModule.使用skip-import选项跳过在NgModule中的导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆