Eleventy "data file could not be parsed" in CI
Eleventy loads every file under the data directory to build the global data cascade. A data file with invalid JSON, or a JS data file that throws on import, stops the whole build.
What this error means
eleventy build fails referencing a file in _data, with a JSON parse error or an exception thrown from the module, before templates render.
[11ty] Error: Data file './src/_data/site.json' could not be parsed.
[11ty] SyntaxError: Unexpected token } in JSON at position 142Common causes
Invalid JSON in a data file
A trailing comma or unquoted key makes a _data/*.json file fail to parse.
A JS data file that throws on load
A _data/*.js module reads an env var or fetches at import; when that is unset or fails in CI, the export throws.
How to fix it
Validate the JSON data file
- Open the named file at the reported position.
- Remove trailing commas and quote all keys.
- Validate it parses, then re-run the build.
node -e "JSON.parse(require('fs').readFileSync('src/_data/site.json','utf8'))"Make JS data resilient in CI
Default missing env vars and handle fetch failures so the module exports cleanly during the build.
export default async function () {
const url = process.env.API_URL;
if (!url) return { items: [] };
// ... fetch and return
}How to prevent it
- Validate JSON data files before committing.
- Default env-dependent JS data so CI never throws on load.
- Keep data files small and free of side effects.