Use Nx run-many to Run Commands in Multiple Projects

Share this video with your friends

Social Share Links

Send Tweet
Published 2 years ago
Updated a year ago

You can run multiple projects using the run-many command from Nx and setting a --target flag with the command you want to run.

For example npx nx run-many --target=build

Instructor: [0:00] We cannot just run a single commands by using nx, let's say, build and then specifying the project such as shared UI, but we can also run a command against multiple projects or all projects in the workspace. [0:12] Similar to the pnpm run -r build, which would run to build command in our projects, the equivalent in Nx would be to use the run-many. We would write something like nx run-many, then we give it a target, which in this case is build or could also be test depending on what you want to run. If we don't provide any parameter, it will just run the build for all the projects.

[0:37] We can also pass the projects in. We could say shared-ui, comma, and some other project if we would have some. For instance, if we use the run-many just on the shared-ui, you can see it just runs on that single one. This is a very useful way to filter out some of the project and running commands against those.

egghead
egghead
~ an hour ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today