Categories
Android Update Internet Latest news Technology Reviews

nx: Recursively Run Scripts in All pnpm Workspace Projects

Instructor: [0:00] We have this Remix app in our apps folder and that shared UI React library node packages folder within our pnpm workspace. We can obviously target the single packages directly using the pnpm filter, let’s say shared UI. Let’s say we want to run the build here, so we run shared UI build, and it is with them build our shared UI package.
[0:24] Sometimes you might want to run commands across all the applications and target, let’s say, all the build commands and build all the apps and libraries there. To do that, we can use the -R commands, which recursively runs a given command.

[0:39] We can run pnpm, run -R, build. What this will do is it figures out which packages need to be run. In this case, it’s packages shared UI and then apps, my Remix app, we’ll run build for both of them. This obviously also works for every other command that you want to run from some package.json script.