title: Angular 2 CLI "ng generate component" command does not find app.module
body: <p>I have been trying to generate new components using Angular2's CLI tool using this command:</p>
  
  <pre><code>ng generate component test
  </code></pre>
  
  <p>After execution, new component files are generated, but the references are not added into the app.module.ts file:</p>
  
  <blockquote>
    <p>No app module found. Please add your new class to your component.</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/CB2kP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CB2kP.png" alt="enter image description here"></a></p>
  
  <p>I was trying to find the solution to fix this so I dont have to always import new component and add it to declarations manually, but I couldn't find anything about this issue online.</p>
  
  <p>I think it may have something to do with my angular-cli.json file, but it seems to be ok:<a href="https://i.stack.imgur.com/7pF3b.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7pF3b.png" alt="enter image description here"></a></p>
  
  <p>Any ideas?</p>
  
  <p>UPDATE:
  This is my project folder structure, simplyfied. I removed folders which are not relevant:</p>
  
  <p><a href="https://i.stack.imgur.com/h7wdS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/h7wdS.png" alt="enter image description here"></a></p>
  
  <p>Code in the app.module.ts is following:</p>
  
  <pre><code>import { NgModule }         from '@angular/core';
  import { BrowserModule }    from '@angular/platform-browser';
  import { HttpModule }       from '@angular/http';
  import { AppComponent }     from './app.component';
  import { SearchComponent }  from './search/search.component';
  
  @
  NgModule({
      declarations: [
          AppComponent,
          SearchComponent
      ],
      imports: [
          BrowserModule,
          HttpModule
      ],
      providers: [
      ],
      bootstrap: [
          AppComponent
      ]
  })
  export class AppModule { }
  </code></pre>