npmmonoreponpm-workspaces

how to delete all node_modules from all packages in npm 7 workspace monorepo


how can I delete all node_modules folders from all packages in an npm 7 workspace?

With Lerna we could just execute lerna clean -y but when migrating to native NPM 7+ workspaces, is there some equivalent?


Solution

  • you can execute this to do so:

    npm exec --workspaces -- npx rimraf node_modules && npx rimraf node_modules
    

    explanation:

    That's all! Good luck