node.jsnpmalibaba-cloudalibaba-cloud-ecs

whether the npm uninstall * command will remove the global installs too while uninstalling the dependencies of package.json or not?


My application is hosted in Alibaba Cloud ECS Instance and I am trying to uninstall the dependencies of the package.json. I understand the npm uninstall * command will uninstall all the dependencies but the question is whether it will remove global installs too or not.


Solution

  • AFAIK there is no uninstalling with a wildcard like npm uninstall * command in npm. The issue is still being opened here https://github.com/npm/npm/issues/19967.

    Use this command to uninstall your global dependencies :

    npm ls -gp --depth=0 | awk -F/ '/node_modules/ && !/\/npm$/ {print $NF}' | xargs npm -g rm

    reference: Command to remove all npm modules globally?