Skip to content

Instantly share code, notes, and snippets.

@Ronin1702
Last active September 26, 2023 11:45
Show Gist options
  • Select an option

  • Save Ronin1702/c39775344c8c800b304eb4e12a903312 to your computer and use it in GitHub Desktop.

Select an option

Save Ronin1702/c39775344c8c800b304eb4e12a903312 to your computer and use it in GitHub Desktop.
Delete `node_modules` folder from your directory

Remove node_modules || package-lock.json || dist Folders

Remove node_modules:

  • In GitBash shell, copy and paste the commeand below in the terminal under your destinated directory:

    find . | grep /node_modules$ | grep -v /node_modules/ | xargs rm -fR

IMPORTANT: Make sure you're operating in the directory you want the node_modules to be deleted. If you you use this command in your root directory of your entire OS, it will delete ALL node_modules.

Remove package-lock.json:

find . | grep /package-lock.json$ | grep -v /package-lock.json/ | xargs rm -fR

Remove dist folder:

find . | grep /dist$ | grep -v /dist/ | xargs rm -fR

All at Once

find . \( -path '*/node_modules' -o -path '*/package-lock.json' -o -path '*/dist' \) -prune -exec rm -fR {} +
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment