Skip to content
Latchkey

NestJS monorepo (apps/libs) build / project not found error in CI

In a Nest monorepo, nest build without a project name, or a missing project entry in nest-cli.json, fails to build the right app. Library imports also fail if the tsconfig path mappings for libs are absent.

What this error means

nest build fails with "project X does not exist" or a compiled app cannot resolve a @app/lib import because the monorepo path mappings did not carry into the build.

NestJS
Error: Project "api" does not exist. Available projects: app, worker.
    at MonorepoLoader.load (/app/node_modules/@nestjs/cli/lib/...)

Common causes

The build did not name the correct project

In monorepo mode nest build needs the project name; omitting it or naming a project not in nest-cli.json fails.

Library path mappings are missing

Imports of shared libs rely on tsconfig paths; if the build tsconfig omits them, the library cannot be resolved.

How to fix it

Build the named project

  1. List projects in nest-cli.json and pick the correct one.
  2. Run nest build <project> for each app you need.
  3. Ensure each project entry has the right sourceRoot and tsConfigPath.
Terminal
nest build api
nest build worker

Register library path mappings

Keep the libs path aliases in the base tsconfig the build extends.

tsconfig.json
{
  "compilerOptions": {
    "paths": { "@app/shared": ["libs/shared/src"], "@app/shared/*": ["libs/shared/src/*"] }
  }
}

How to prevent it

  • Build each monorepo project explicitly by name in CI.
  • Keep library path mappings in a shared base tsconfig.
  • Verify nest-cli.json lists every app and library correctly.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →