Getting Started with NX in your Workspace: An Installation Guide

How to add Nx to the workspace and running Nx commands

Project Source Code

Get the project source code below, and follow along with the lesson material.

Download Project Source Code

To set up the project on your local machine, please follow the directions provided in the README.md file. If you run into any issues with running the project source code, then feel free to reach out to the author in the course's Discord channel.

This lesson preview is part of the The Art of Enterprise Monorepos with Nx and pnpm course and can be unlocked immediately with a \newline Pro subscription or a single-time purchase. Already have access to this course? Log in here.

This video is available to students only
Unlock This Course

Get unlimited access to The Art of Enterprise Monorepos with Nx and pnpm, plus 70+ \newline books, guides and courses with the \newline Pro subscription.

Thumbnail for the \newline course The Art of Enterprise Monorepos with Nx and pnpm
  • [00:00 - 00:20] Hi, in this lesson we are planning to install NX in our workspace. NX can be installed globally but my preference is to install it as a project dependency. This allows for definition of a specifics version, ensuring consistency across various local and remote environments. To add NX to our workspace, we use pnpm add command.

    [00:21 - 00:35] Here we pass in NX we use -w command to run as if pnpm was started in the root of the workspace instead of the current working directory. And -d is to install NX as a dependency.

    [00:36 - 01:04] Now we have NX installed we can replace pnpm command with the NX command. So we start with NPX, NX and the command we need to run. For example, if you want to run the front-end application, the command for running it is start.

    [01:05 - 01:17] So we type start and then the package name. And this runs the command successfully.

    [01:18 - 01:43] The reason why we use NPX is because it's using the local installed NX package. The syntax for NX is always followed by the target and the project as depicted in here. In this example, we are using NPX to run NX command followed by the target, the start or the command that you run and then the project is front-end.

    [01:44 - 01:54] Great. In this lesson we learned how to add NX to our workspace. and use NX instead of pmp commands.