“rm -rf” equivalent for Windows?

前端 未结 21 1541
一向
一向 2020-11-27 08:40

I need a way to recursively delete a folder and its children.

Is there a prebuilt tool for this, or do I need to write one?

DEL /S doesn\'t dele

21条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 09:30

    The accepted answer is great, but assuming you have Node installed, you can do this much more precisely with the node library "rimraf", which allows globbing patterns. If you use this a lot (I do), just install it globally.

    yarn global add rimraf
    

    then, for instance, a pattern I use constantly:

    rimraf .\**\node_modules
    

    or for a one-liner that let's you dodge the global install, but which takes slightly longer for the the package dynamic download:

    npx rimraf .\**\node_modules
    

提交回复
热议问题