I am working on angular2 for my new project, newly with this technology. I have set-up my project with angular CLI (Reference site https://github.com/angular/angular-cli).
I have created 4 components using command ng generate component my-new-component
For testing purpose, created one component app-testing, need to remove that component from my project. Else need to rename for that component. I have tried several like. ng destroy component app-testing
but showing error The destroy command is not supported by Angular-CLI., Please help me with solution.
Thanks in advance.
This question is related to
angular
angular-cli
No As of now you can't do this by any command. You've to remove Manually from app.module.ts
and app.routing.module.ts
if you're using Angular 5
You should remove your component manually, that is...
[name].component.ts
[name].component.html // if you've used templateUrl in your component
[name].component.spec.ts // if you've created test file
[name].component.[css or scss] // if you've used styleUrls in your component
If you have all that files in a folder, delete the folder directly.
Then you need to go to the module which use that component and delete
import { [component_name] } from ...
and the component on the declarations array
That's all. Hope that helps
This is the NPM known Issue for windows that NPM is pretty much unusable under Windows. This is of course related to the path size limitations.
https://github.com/npm/npm/issues/5641
My main concern here is that there are no mention of these issues when installing node or npm via the website. Not being able to install prime packages makes npm fundamentally unusable for windows.
I had the same issue, couldn't find a right solution so I have manually deleted the component folder and then updated the app.module.ts file (removed the references to the deleted component) and it worked for me.
Try to uninstall angular and then reinstall
npm uninstall --save @angular/(then whatever component you want deleted)
after that, a box with babyblue color border will appear with suggestion to update and install angular back up.
I tried ng remove component Comp_Name also ng distroy component but it is not yet supported by angular so the best option for now is to manually remove it from the folder structure.
You can delete any component by removing all its lines from app.module.ts . Its working fine for me.
There's the --dry-run
flag which will allow you to preview the changes, and/or you can use the Angular Console App to generate the cli flags for you, using their easy GUI. It auto-previews everything before you commit to it.
version control is your friend here, do a diff
or equivalent and you should see what's been added/modified.
In fact, removing the component folder might not be enough; with Angular-CLI v1.0, the command ng generate component my-new-component
also edits your app.module.ts
file by adding the respective import
line and the component to the providers
array.
Source: Stackoverflow.com