Delete node_modules folder recursively from a specified path using command line

后端 未结 7 1903
暖寄归人
暖寄归人 2021-01-29 18:26

I have multiple npm projects saved in a local directory. Now I want to take backup of my projects without the node_modules folder, as it is taking a lot of space a

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-29 18:41

    Print out a list of directories to be deleted:

    find . -name 'node_modules' -type d -prune
    

    Delete directories from the current working directory:

    find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +
    

    Alternatively you can use trash (brew install trash) for staged deletion:

    find . -name node_modules -type d -prune -exec trash {} +
    

提交回复
热议问题