Did you update the angular-cli to latest version? or did you try updating node or npm or typescript? this issue comes because of versions like angular/typescript/node. If you are updating the cli, use this link here.
https://github.com/angular/angular-cli/wiki/stories-1.0-update
ng generate component component_name was not working in my case because instead of using 'app' as project folder name, I renamed it to something else.
I again changed it to app.
Now, it is working fine
ng g c --dry-run so you can see what you are about to do before you actually do it will save some frustration. Just shows you what it is going to do without actually doing it.
go to your angular project folder and open the command promt an type "ng g component header"
where header is the new component that you want to create.As default the header component will be created inside the app component.You can create components inside a component .For example if you want to create a component inside he header that we made above then type"ng g component header/menu". This will create a menu component inside the header component
There are mainly two ways to generate new component in Angular,
using ng g c <component_name> , another way is that using ng generate component <component_name>. using one of these commands new component can be generated.