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
- List projects in nest-cli.json and pick the correct one.
- Run
nest build <project>for each app you need. - Ensure each project entry has the right sourceRoot and tsConfigPath.
Terminal
nest build api
nest build workerRegister 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
NestJS jest "Cannot find module '@app/...'" path alias (moduleNameMapper) in CIFix NestJS jest "Cannot find module '@app/...'" in CI - tsconfig path aliases are not mapped in jest, so add…
NestJS "nest: command not found" (@nestjs/cli) in CIFix "nest: command not found" in CI - the @nestjs/cli is a devDependency that was not installed, or the build…
NestJS "nest build" error TS with decorators / emitDecoratorMetadata in CIFix "nest build" TypeScript errors about decorators in CI - tsconfig is missing experimentalDecorators or emi…