How to navigate a JavaScript monorepo without getting lost
Apps, packages, workspaces and task pipelines: how to find your way around a Turborepo, Nx or pnpm monorepo and understand how its pieces depend on each other.
A monorepo puts many projects in one repository: several apps, shared packages, configuration and tooling. That makes sharing code easy and understanding it harder, because the boundaries between projects aren't obvious from the folder tree. Here's how to orient yourself.
Step 1: find the workspace definition
The list of projects lives in one of these:
pnpm-workspace.yamlfor pnpm- The
workspacesfield in the rootpackage.jsonfor npm and Yarn nx.jsonplusproject.jsonfiles for Nxturbo.jsonfor Turborepo tasks (projects still come from the package manager)
List every project and write one line about each. That list is your map.
Step 2: separate apps from packages
Apps are deployed: a web front end, an API, a docs site. Packages are shared code: a UI kit, a database client, config presets, utilities. Most monorepos use apps/ and packages/ (or libs/ in Nx) to make the split visible.
Step 3: draw the dependency graph between projects
Each project's package.json lists internal dependencies, often with versions like workspace:*. Tools draw this for you:
nx graphfor Nxpnpm why <package>orpnpm -r list --depth -1for pnpmturbo run build --graphfor Turborepo
Once you know which packages an app uses, you can ignore everything else.
Step 4: understand how packages are consumed
This detail causes many confusing errors. A shared package can be consumed as:
- Source. The app's bundler compiles the package's TypeScript directly. Changes appear instantly.
- Built output. The package must be built first, and the app imports
dist/. Stale builds cause "but I changed that" moments.
Check the package's main, exports and types fields to see which one applies.
Step 5: learn the task pipeline
turbo.json or nx.json defines how tasks like build, test and lint depend on each other. dependsOn: ["^build"] means "build my dependencies first". Caching means a task may not rerun if its inputs didn't change. Knowing this explains why CI is fast, or why it isn't.
Step 6: find shared configuration
Monorepos centralise configuration: base tsconfig files, ESLint configs and environment handling. When an app behaves strangely, check whether it extends a shared config.
Step 7: work within one project at a time
Treat each app as its own codebase with known dependencies. Investigate a feature inside the app first, and only follow imports into packages when the path leads there.
Using RepoGrasp on a monorepo
Large monorepos often exceed the preview's limit of about 200,000 tokens of source. Link to one project instead, for example github.com/owner/repo/tree/main/apps/web, and ask about that app. For a question that spans a package, link the package folder separately.
Pitfalls
- Path aliases in
tsconfigthat make local packages look like npm packages - Two packages depending on different versions of the same library
- Circular dependencies between packages, which tools may tolerate but humans can't follow
See also our guides to Turborepo, Nx and pnpm workspaces.