Installation
You don't have to install Nx but you can rather just create a new workspace with the create-nx-workspace
command:
npm create nx-workspace
This will guide you through the setup, asking whether you want a monorepo or a standalone app and whether you want to start with a blank template or with a preconfigured template.
~/workspace❯
npm create nx-workspace
? Choose what to create …
Package-based monorepo: Nx makes it fast, but lets you run things your way.
Integrated monorepo: Nx configures your favorite frameworks and lets you focus on shipping features.
Standalone React app: Nx configures Vite (or Webpack), ESLint, and Cypress.
Standalone Angular app: Nx configures Jest, ESLint and Cypress.
Standalone Node app: Nx configures a framework (ex. Express), esbuild, ESlint and Jest.
Installing Nx into an existing repository
You can just add the nx
package to your existing repository.
Installing Nx Globally
If you really want to install Nx globally, you can. Depending on your package manager of choice, use one of the following commands:
npm install --global nx@latest
With a global Nx installation, Nx looks for the local copy of Nx in your repo and hands off the process execution to it. This means that whichever version of Nx is installed locally in your repo is still the version of Nx that runs your code. For the most part, this can eliminate any issues that may arise from the global install being outdated.