# Log in as root (might be required depending on install)su -# List all global packagesnpm ls -g --depth=0# List all local (project) packagesnpm ls -p --depth=0# Remove all global packagesnpm ls -g --depth=0 | awk -F/ '/node_modules/ && !/\/npm$/ {print $NF}' | xargs npm -g rm# Remove all local packgesnpm ls -p --depth=0 | awk -F/ '/node_modules/ && !/\/npm$/ {print $NF}' | xargs npm -p rm# NOTE (optional): to use node with sudo you can add the bins to /usr/bin# NOTE $PATHTONODEINSTALL is where node is installed (e.g. /usr/local/node)sudo ln -s $PATHTONODEINSTALL/bin/node /usr/bin/nodesudo ln -s $PATHTONODEINSTALL/bin/npm /usr/bin/npm
↧
Answer by snassr for How can I uninstall npm modules in Node.js?
↧