Angular2: Rename component

7.5k views Asked by At

I need to rename a component in my Angular2 application. I renamed all the files in the component folder (from x.component.* to y.component.*) and the folder itself (from x to y). I also updated files:

  • y.component.ts: renamed templateUrl/styleUrls
  • app.routing.ts
  • app.module.ts

After that I wanted to restart ng server with 'ng s', but now it says "You have to be inside an angular-cli project in order to use the serve command."

So, is there a "standard protocol" for renaming components in Angular2? Am I forgetting something? Or is it just impossible to do that and the only option is to create a new one, copy everything there, and delete the old one?

Thank you!

1

There are 1 answers

0
Damian O'Brien On BEST ANSWER

Im not 100% sure about the problem youre having but i got that message too after cloning from github. Im going to assume you have the angular-cli and node.js installed, so cd into the root directory of your project and type

ng init

this worked for me, i havent a clue why but my guess is that by moving things around or changing them makes the cli confused and it ends up ignoring the project. Hope this works for you!