Installation
You don't have to install Nx, but you can rather 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 or 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.
Once you've created your workspace, you can
- run single tasks with
npx nx <target> <project>
- run multiple tasks with
npx nx run-many --targets=<target1>,<target2>
Learn more about running tasks.
Installing Nx into an Existing Repository
If you alrady have a rfepository, run
npx nx@latest init
You can also manually install the nx NPM package and create a nx.json to configure it. Learn more about adopting Nx in an existing project
Installing Nx Globally
You can install Nx globally. Depending on your package manager of choice, use one of the following commands:
npm install --global nx@latest
The advantage of a global installation is that you don't have to prefix your commands with npx
(or the other package manager's corresponding alternatives). Instead you can directly run nx run-many -t test
. The global Nx installation then automatically hands off the process execution to the local Nx installion in your repository. This can eliminate any issues arising from the outdated global install.
Learn more about managing and troubleshooting a global Nx installation.