badges/shields · error · NotFound
no nyc or c8 stanza found
Error message
no nyc or c8 stanza found
What it means
The nycrc service fetches a JSON config file from the repository (package.json by default, or a named config file) and expects either a `c8` or `nyc` key holding coverage settings. If neither key exists in the parsed JSON, it throws NotFound with this message, indicating the repo does not carry an nyc/c8 coverage stanza.
Source
Thrown at services/nycrc/nycrc.service.js:124
prettyMessage: '"branches" or "lines" threshold missing',
})
}
}
async handle({ user, repo }, queryParams) {
const { config, preferredThreshold } = queryParams
let coverage
if (config.includes('package.json')) {
const pkgJson = await fetchJsonFromRepo(this, {
schema: pkgJSONSchema,
user,
repo,
branch: 'HEAD',
filename: config,
})
const nycConfig = pkgJson.c8 || pkgJson.nyc
if (!nycConfig) {
throw new NotFound({
prettyMessage: 'no nyc or c8 stanza found',
})
} else {
coverage = this.extractThreshold(nycConfig, preferredThreshold)
}
} else {
coverage = this.extractThreshold(
await fetchJsonFromRepo(this, {
schema: nycrcSchema,
user,
repo,
branch: 'HEAD',
filename: config,
}),
preferredThreshold,
)
}
return this.constructor.render({ coverage })View on GitHub (pinned to 766fd8bc89)
Solutions
- Add an `nyc` (or `c8`) stanza with thresholds to package.json in the target repo.
- Or move/keep the config in .nycrc and pass the correct `config` filename parameter to the badge.
- Confirm the repo/branch in the badge URL actually contains the config file.
Example fix
// before (package.json)
{ "name": "mylib" }
// after
{ "name": "mylib", "nyc": { "lines": 90, "branches": 80 } } Defensive patterns
Strategy: validation
Validate before calling
const pkg = require('./package.json')
if (!pkg.nyc && !pkg.c8) {
throw new Error('Add an nyc or c8 stanza to package.json before using the nycrc badge')
} Type guard
function hasCoverageStanza(pkg) {
return pkg && typeof pkg === 'object' &&
(pkg.nyc != null || pkg.c8 != null)
} Try / catch
try {
const coverage = await getNycrcBadge(repo)
} catch (e) {
if (e.message === 'no nyc or c8 stanza found') {
// repo has no coverage config: hide badge or show 'unknown'
} else { throw e }
} Prevention
- Add the nyc/c8 config to package.json (or pass the right config filename param)
- Match the badge's config parameter to where your config actually lives
- Keep key names lowercase: nyc and c8, never NYC
When it happens
Trigger: Requesting the nycrc badge for a repo whose fetched config JSON has no `nyc` and no `c8` key — including when the config filename points at a non-package JSON file without those keys.
Common situations: Projects using vitest/jest coverage or a separate .nycrc file while the badge reads package.json; typos like "NYC"; config stored under a different filename than the badge's `config` param expects.
Related errors
- "${preferredThreshold}" threshold missing
- "branches" or "lines" threshold missing
- not enabled for this project
- not set up
- coverage not found
AI-assisted analysis of badges/shields@766fd8bc89 (2026-08-30).
Data as JSON: /api/errors/ba2006e063d29d6d.
Report an issue: GitHub.