• Register
0 votes

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

1 vote
1 answer 1.3K 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 40 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 14 views
I was working on that but I got into some problems.
asked Dec 1, 2020 TeamScript 9.5k points
0 votes
2 answers 61 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
0 votes
1 answer 110 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
0 votes
1 answer 74 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, 2020 quizzBabes 160 points
0 votes
1 answer 236 views
Problem : Currently I am learning Ionic I have recently created the ionic 2 project and also added the diagnostic cordova plugin as below: ionic plugin add cordova.plugins.diagnostic npm install --save @ionic-native/diagnostic and after that added the android platform as ... system to install the gradle wrapper. Please include gradle in your path, or install Android Studio How to fix above error?
asked Feb 26, 2020 mphil 2.3k points
0 votes
1 answer 15 views
Problem: So I have an MVC application where I am trying to send an email from an Angular form running on a DotNet server. The main problem I see is that when I call the service from my Angular component, it returns 404 (URL not found maybe). Now I have a message in my controller that ...         }     } } Now I can't figure out why it can't talk to the controller. Is there something I am missing?
asked Dec 7, 2020 sasha 5.3k points
0 votes
1 answer 665 views
Problem: I am facing following error if I tried to use a MatToolBar in my angular app. In browser I receive: Uncaught TypeError: Object(...) is not a function I also receive below warnings in my console: WARNING in ./node_modules/@angular/cdk/esm5/text-field.es5.js ... /cdk/esm5/a11y.es5.js 2324:206-214 "export 'ɵɵinject' was not found in '@angular/core' Kindly guide me in resolving above errors.
asked Aug 18, 2020 Raphael Pacheco 4.9k points