• Register
0 votes
1.5k 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

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

1 vote
1 answer 1.1K views
1.1K 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
0 votes
2 answers 40 views
40 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 mphil 2.3k points
1 vote
1 answer 34 views
34 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 Martin K 6.6k points
0 votes
1 answer 18 views
18 views
Problem: I am getting following message when i run angualr2 program with typescript. angular is running in the development mode. call enableprodmode() to enable the production mode. What is the reason for this message is it a deployment option? Curious for feedback ?
asked Jul 16 quizzBabes 160 points