Run Commands with Nx

Share this video with your friends

Social Share Links

Send Tweet
Published 2 years ago
Updated a year ago

Nx provides you with a more convenient syntax to run commands within your workspace projects.

Either nx <target> <project> or nx run <project>:<target> will work, but usually the first one is more convenient to use.

Instructor: [0:00] Now, we could actually use Nx to issue commands against our pnpm workspace packages. Rather than running something like pnpm. That's just filter shared-ui build, Nx uses a syntax which is the following. It is always Nx then the target that we want to run -- in this case, build, for instance -- and then the project that we want to run. [0:22] Or alternatively, we could also use Nx run and then project:target. This is really what you prefer. Usually, this is the easier syntax.

[0:34] To test this out, we could just run Nx, and I just prefix it here with npx or pnpx to reference the local package that lives here in that Node module's folder. I could also install it globally, but I use here npx Nx and then we want to run the build for the shared UI, for instance. You can see how it runs that build.

[0:56] Similarly, that will work for my remix app. You can see Nx already figures out where those packages are, where the specific build command is located by looking at the package.json scripts, and so then runs exactly those scripts which are in here.

egghead
egghead
~ just now

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