Skip to content

Add to an Existing Project

Let an AI agent set it up for you

Help me add Nx to my existing repository.

1. Run `npx nx@latest init` from the repo root and walk me through the prompts. Do not pass `--interactive=false`, the answers depend on how my repo is laid out.

2. Show me the diff. `nx.json` is new, and `package.json` gains an `nx` devDependency. Scripts should be left alone.

3. Run `npx nx run-many -t build` to confirm tasks still work, then run it a second time so I can see the cache hit.

4. Run `npx nx graph` and walk me through the project graph.

Stage what changed but do not commit. Do not add plugins or restructure the repo unless I ask.

Page: https://nx.dev/docs/getting-started/start-with-existing-project.md

Help me add Nx to my existing repository.

1. Run `npx nx@latest init` from the repo root and walk me through the prompts. Do not pass `--interactive=false`, the answers depend on how my repo is laid out.

2. Show me the diff. `nx.json` is new, and `package.json` gains an `nx` devDependency. Scripts should be left alone.

3. Run `npx nx run-many -t build` to confirm tasks still work, then run it a second time so I can see the cache hit.

4. Run `npx nx graph` and walk me through the project graph.

Stage what changed but do not commit. Do not add plugins or restructure the repo unless I ask.

Page: https://nx.dev/docs/getting-started/start-with-existing-project.md

Nx is designed for incremental adoption. Start with task running and caching, then add plugins, CI integrations, or other capabilities as your needs grow.

From PNPM Workspaces to Distributed CI

Watch full course

Add Nx to any existing project with a single command:

Terminal window
$ npx nx@latest init
detecting workspace structure
adding Nx to package.json
ready in 12s

Whether a monorepo, single project, or something in between, nx init walks you through adding and configuring Nx. At the end you'll have an Nx workspace ready for anything.

After initializing Nx, try these commands:

Terminal window
nx build <project-name> # Run a task
nx build <project-name> # Run again - instant cache hit
nx run-many -t build test # Run tasks across all projects
nx graph # Visualize project dependencies

From here you can: