Skip to content

Instantly share code, notes, and snippets.

@bolencki13
Created February 1, 2019 20:34
Show Gist options
  • Save bolencki13/9559237da4f0e9dab4ae1374ccb8adb7 to your computer and use it in GitHub Desktop.
Save bolencki13/9559237da4f0e9dab4ae1374ccb8adb7 to your computer and use it in GitHub Desktop.
Remove all global npm packages
npm r -g $(node -e "console.log(process.argv.filter((e) => e !== '├──' && e !== '└──').filter((_, i) => i > 1).map((e) => e.split('@')[0]).filter((e) => e !== 'npm').join(' '))" $(npm list -g -depth 0))
npm r -g (node -e "console.log(process.argv.filter((e, i) => e && i > 1).map((i) => i.split(' ')[1].split('@')[0]).filter((i) => i !== 'npm').join(' '))" (npm list -g -depth 0))
@bolencki13
Copy link
Author

A simple script that removes all npm packages. This was tested on macOS using both Fish & Bash shells.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment