|
| 1 | +--- |
| 2 | +name: vercel-root-directory-cli |
| 3 | +description: 'Skill: vercel-root-directory-cli' |
| 4 | +--- |
| 5 | + |
| 6 | +# Vercel Root Directory vs CLI Deploy |
| 7 | + |
| 8 | +## Problem |
| 9 | + |
| 10 | +`vercel build` can pass while `vercel deploy` fails in a monorepo because the Vercel project is configured |
| 11 | +with a subdirectory Root Directory, but `vercel.json` sits at the repo root. |
| 12 | + |
| 13 | +## Context / Trigger Conditions |
| 14 | + |
| 15 | +Use this rule when all of these smell true: |
| 16 | + |
| 17 | +- The Vercel project Root Directory is set to something like `apps/www` |
| 18 | +- `vercel.json` is at the repo root instead of inside that Root Directory |
| 19 | +- `vercel deploy` or `vercel deploy --prebuilt` fails with `The vercel.json file should be inside of the provided root directory` |
| 20 | +- The dashboard can still build because "Include files outside the root directory" is enabled |
| 21 | + |
| 22 | +## Solution |
| 23 | + |
| 24 | +1. Check the Vercel project Root Directory with `vercel project inspect`. |
| 25 | +2. Check where `vercel.json` actually lives. |
| 26 | +3. If Root Directory is a subdirectory, either: |
| 27 | + - move `vercel.json` into that Root Directory, or |
| 28 | + - change the Vercel project Root Directory back to repo root. |
| 29 | +4. Do not treat this as an app source failure unless `vercel build` reproduces it. |
| 30 | + |
| 31 | +## Verification |
| 32 | + |
| 33 | +- `vercel build` succeeds locally from the expected project root |
| 34 | +- `vercel project inspect` reports a Root Directory that matches where `vercel.json` lives |
| 35 | +- `vercel deploy` no longer fails with the root-directory error |
| 36 | + |
| 37 | +## Example |
| 38 | + |
| 39 | +- Repo root contains `vercel.json` |
| 40 | +- Vercel project Root Directory is `apps/www` |
| 41 | +- Dashboard builds may still work with files outside the root included |
| 42 | +- CLI deploy fails because it expects `vercel.json` inside `apps/www` |
| 43 | + |
| 44 | +## Notes |
| 45 | + |
| 46 | +- "Include files outside the root directory" helps the build step see workspace files. It does not make CLI config validation ignore the Root Directory boundary. |
| 47 | +- If the latest app error only appeared in remote logs, reproduce first with `vercel build` before changing source files. |
| 48 | + |
| 49 | +## References |
| 50 | + |
| 51 | +- https://vercel.com/docs/monorepos |
| 52 | +- https://vercel.com/docs/deployments/configure-a-build#root-directory |
0 commit comments