generator-jhipster: error with generating new component by angular-cli

Trying generate new angular component by follow command: $ ng g c sidebar I got error message: Error: Could not find an NgModule for the new component. Use the skip-import option to skip importing components in NgModule. Could not find an NgModule for the new component. Use the skip-import option to skip importing components in NgModule.

When I try generate new component without import ( -skip-import option) new component added with wrong path: $ ng g c sidebar -skip-import create src/main/webapp/src/main/webapp/app/sidebar/sidebar.component.html (26 bytes) create src/main/webapp/src/main/webapp/app/sidebar/sidebar.component.ts (245 bytes)

JHipster Version(s)
demoissue@0.0.0 JHIPSTER-projects\demoissue
`-- generator-jhipster@4.10.0
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
                                                                                                                        
{                                                                                                                            
  "generator-jhipster": {                                                                                                    
    "promptValues": {                                                                                                        
      "packageName": "com.fiveplus.cosmo"                                                                                    
    },                                                                                                                       
    "jhipsterVersion": "4.10.0",                                                                                             
    "baseName": "demoissue",                                                                                                 
    "packageName": "com.fiveplus.cosmo",                                                                                     
    "packageFolder": "com/fiveplus/cosmo",                                                                                   
    "serverPort": "8080",                                                                                                    
    "authenticationType": "jwt",                                                                                             
    "hibernateCache": "ehcache",                                                                                             
    "clusteredHttpSession": false,                                                                                           
    "websocket": false,                                                                                                      
    "databaseType": "sql",                                                                                                   
    "devDatabaseType": "postgresql",                                                                                         
    "prodDatabaseType": "postgresql",                                                                                        
    "searchEngine": false,                                                                                                   
    "messageBroker": false,                                                                                                  
    "serviceDiscoveryType": false,                                                                                           
    "buildTool": "maven",                                                                                                    
    "enableSocialSignIn": false,                                                                                             
    "enableSwaggerCodegen": false,                                                                                           
    "jwtSecretKey": "replaced-by-jhipster-info",                                                                             
    "clientFramework": "angularX",                                                                                           
    "useSass": false,                                                                                                        
    "clientPackageManager": "yarn",                                                                                          
    "applicationType": "monolith",                                                                                           
    "testFrameworks": [],                                                                                                    
    "jhiPrefix": "jhi",                                                                                                      
    "enableTranslation": false                                                                                               
  }                                                                                                                          
}                                                                                                                            
##### **JDL for the Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**
JDL entity definitions
                                                                                                                        
##### **Environment and Tools**

java version “1.8.0_101”
Java™ SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot™ 64-Bit Server VM (build 25.101-b13, mixed mode)

git version 2.13.0.windows.1

node: v6.11.3

npm: 5.4.2

bower: 1.8.0

yeoman: 2.0.0

yarn: 1.0.2

Browsers and Operating System

OS: windows 7

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 24 (6 by maintainers)

Most upvoted comments

If you are working in your current project directory, just change it to /src/app and then run the command ‘ng g c your-component’ and your component will be generated. It worked for me.

It looks you are not in the right directory -> in which directory do you run those commands?

Can confirm this issue, generating components is partly broken with 6.0.8, it seems to work when you navigate to src/app.

I have the same message error in Windows 10. I have tested in MacOS (10.12.5) and it works

when I try to pull other’s code, ionic-cli or ng-cli will generate parts of fill such as *-base*-ours*-theirs. I delete them and I can use ng g c * successfully.

I was using ionic and tried everything. But this is the only thing that worked. Specifying the root module like this…

ionic g page page-name --module app.module.ts

where g can be generate and page can be component too.

Notice the syntax of --module, because for me --module=‘app.module.ts’ didn’t work. Hope this helps someone.

Hello I got the same error: “ng generate component home Could not find an NgModule. Use the skip-import option to skip importing in NgModule.”

I got this error using Angular 6 and this error is why I changed the root value in angular.json, it was: root: “src”, I changed again it to root: “” and the error was fixed

in .angular-cli.json in part “apps” replace “./src” to “src”

“apps”: [ { “root”: “src”, “outDir”: “dist”,

As Julien, I can’t reproduce. But after investigating, the problem comes directly from angular/cli: look at this ticket https://github.com/angular/angular-cli/issues/7960 -> it’s related to Windows7 and the shell you used to execute the command

As it’s not on our side, I’m closing this.