Nx "inputs"/"outputs" Misconfig - Cache Misses & Empty Replays
Nx caches a task by hashing its inputs and storing its declared outputs. When outputs point at the wrong directory, nothing is cached to replay; when inputs are wrong, the hash never matches and every run misses.
What this error means
CI rebuilds a task every run despite no source change, or a cache "hit" restores nothing because the outputs were never captured. Nx may warn that a task produced no outputs at the declared path.
NX Nx captured no outputs for the task "web:build".
The "outputs" do not match any files. Did the build write to dist/web,
not the declared "{projectRoot}/dist"?Common causes
Outputs path does not match where the build writes
If outputs is {projectRoot}/dist but the build emits to dist/apps/web at the workspace root, Nx caches nothing and later restores nothing.
Inputs omit files that affect the build
Leaving a config file (tsconfig, env, schema) out of inputs means the hash misses a real input - stale hits or confusing misses follow.
Inputs include volatile files
Including timestamps, logs, or generated files in inputs makes the hash change every run, so the task never hits the cache.
How to fix it
Point outputs at the real artifact path
Declare exactly where the task writes so Nx can capture and replay it.
{
"targets": {
"build": {
"outputs": ["{workspaceRoot}/dist/apps/web"],
"inputs": ["production", "^production"]
}
}
}Define precise named inputs
Capture everything that affects output and exclude what does not, so the hash is stable and complete.
{
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"production": ["default", "!{projectRoot}/**/*.spec.ts"]
}
}Inspect what was hashed and captured
NX_VERBOSE_LOGGING=true nx run web:build
nx run web:build --verbose # shows captured outputsHow to prevent it
- Keep
outputsin lockstep with the build’s actual output directory. - List every config input in
inputs; exclude volatile/generated files. - Verify caching with a second run that reports a replay, not a rebuild.