• Register
0 votes
2.2k views

Problem :

I am facing following error when I try to use the CLI to create a new component :

Could not find an ngmodule. use the skip-import option to skip importing in ngmodule.    

using below command : 

ng g c my-component --project=my-project 

But no component is created.

I also tried by dropping the --project flag entirely so just used ng g c my-component but still I am facing the same issue. Not sure how to get rid of it.

Any pointers regarding how to fix this issue?

My Environment is as follows :

1.      Angular CLI:-  6.0.8

2.      Node:-  8.9.4

3.      OS:-  win32 x64

4.      Angular:-  6.0.6

5.      Rxjs:-  6.2.1

6.      Typescript:-  2.7.2

7.      Webpack :-  4.8.3

8.      nrwl/nx:-  6.1.0

6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

Generate components command aims to do two things as follows :

·    To create the source code for the component

·    To registers the component in the module by default it will be present in the app.module.ts

The most important issue is, that you don't have the app.module.ts.

In that case there are 2 possible solutions:

1.  By doing the registration of the component in manual manner using following command. It is the easiest way.

ng g component mycomponent --skip-import

2.   By specifying the module with the -m switch. Please refer  link for long thread on it here: https://github.com/nrwl/nx/issues/526

9 7 4
38,600 points

Related questions

0 votes
1 answer 10 views
10 views
Problem: I am facing the following problem : Could not find an ngmodule. use the skip-import option to skip importing in ngmodule .
asked Mar 13 Wafa Abu Yousef 6.1k points
0 votes
1 answer 16 views
16 views
Problem: I am having issues with " appears in the ngmodule.imports of appmodule, but could not be resolved to an ngmodule class ”. Any recomendation on how to solve this?
asked Apr 6 munim01 12.9k points
0 votes
1 answer 3 views
3 views
Problem: HELP! i need help to understand this problem? component is not part of any ngmodule
asked 3 days ago Rohit kr 16.2k points
0 votes
1 answer 158 views
158 views
Problem : I am very new to the Linux but want to set up my MySQL databases on the Amazon ec2 instance. I have followed some directions I found about resetting a user login pass by using a --skip-grant-tables option of the MySQL. Now I want to add my user ... HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement How can I turn above option off?
asked Jan 30, 2020 jwilliam 3.9k points
1 vote
1 answer 1.6K views
1.6K views
Problem : I am very new to deep learning using Keras-TensorFlow in the PyCharmCE environment I am facing below error while working : raise ImportError('Could not import PIL.Image. ' ImportError: Could not import PIL.Image. The use of array_to_img requires PIL.
asked Dec 28, 2019 alecxe 7.5k points
1 vote
1 answer 51 views
51 views
Problem: I have gained fundamental knowledge on Angular2. I am taking help of online tutorials to learn Angular2. I am trying to create the angular 2 App with the angular cli I have written below command in my cmd: npm install angular-cli -g After above command I am ... an error . I am unable to debug above error. I need Angular2 expert who can help me in fixing above Angular2 error for me.
asked Jun 5, 2020 Martin K 6.6k points
0 votes
1 answer 4 views
4 views
Problem I want to use angular material in angular 6,help me to do it.
asked Apr 7 salim1 39k points
0 votes
1 answer 27 views
27 views
I was working on that but I got into some problems.
asked Dec 1, 2020 TeamScript 13.5k points
0 votes
2 answers 99 views
99 views
Problem : Currently I am trying to learning angular 2 and angular CLI also I am using the angular CLI and angular 2 for a very first time to create the sandbox project. I ran the following command "ng serve" and it worked for me. After that I wanted to stop the command so ... port." I am trying to fix this error from past couple of days but unable to fix it. Can somebody help me in fixing it ?
asked Feb 24, 2020 mphil 2.3k points