npm list global packages remove code example
Example 1: how to uninstall global package npm
npm uninstall -g <package-name>
# example
npm uninstall -g webpack
Example 2: remove all packages npm
npm ls -gp --depth=0 | awk -F/ '/node_modules/ && !/\/npm$/ {print $NF}' | xargs npm -g rm