Removing node_modules in all packages in lerna

May 07, 2019

Lerna lets you run commands and scripts in all packages, and it's sometimes necessary to perform scripts that remove certain files such as node_modules or .lock files.

Use lerna exec:

Using lerna exec you can easily remove files or folders across all your packages (keep in mind this wouldn't execute in the project root):

lerna exec -- rm -rf ./node_modules