gatsbyjs/gatsby · error
EnsureResources was not able to find resources for path: "${
Error message
EnsureResources was not able to find resources for path: "${this.props.location.pathname}"
This typically means that an issue occurred building components for that path.
Run `gatsby clean` to remove any cached elements. What it means
Thrown by the EnsureResources React component when it cannot find page resources for the current location pathname, or when those resources have an Error status. EnsureResources is responsible for loading the JS chunk and page-data JSON for a route before rendering; if the resources are missing or errored during build, the component throws (or re-throws a captured build error).
Source
Thrown at packages/gatsby/cache-dir/ensure-resources.js:112
}
return shallowCompare(this, nextProps, nextState)
}
render() {
if (
process.env.NODE_ENV !== `production` &&
(!this.state.pageResources ||
this.state.pageResources.status === PageResourceStatus.Error)
) {
const message = `EnsureResources was not able to find resources for path: "${this.props.location.pathname}"
This typically means that an issue occurred building components for that path.
Run \`gatsby clean\` to remove any cached elements.`
if (this.state.pageResources?.error) {
console.error(message)
throw this.state.pageResources.error
}
throw new Error(message)
}
return this.props.children(this.state)
}
}
export default EnsureResources
View on GitHub (pinned to 8b06340921)
Solutions
- Run `gatsby clean` to remove .cache and public, then rebuild.
- Check the build output for errors on the specific path — a page-level build error often leaves pageResources in an Error state.
- Verify the path exists in your site's generated pages (check public/page-data/ for the corresponding JSON).
- If the error includes pageResources.error, read that error's stack — it is the root cause of the failed page build.
Example fix
# before — stale cache after a failed build npm run build # partial failure, .cache is corrupt # after gatsby clean npm run build # fresh build
Defensive patterns
Strategy: fallback
Try / catch
// Wrap EnsureResources-dependent rendering in an error boundary
import React from 'react'
class ResourceErrorBoundary extends React.Component {
state = { hasError: false }
static getDerivedStateFromError() { return { hasError: true } }
render() {
if (this.state.hasError) {
return <div>Page unavailable. Try refreshing.</div>
}
return this.props.children
}
} Prevention
- Run `gatsby clean` after any failed build before retrying.
- Monitor build CI for page-level errors — fix them before deploying.
- Deploy only complete, successful builds — never partial output.
- Implement a client-side error boundary to gracefully handle missing resources.
When it happens
Trigger: Client-side navigation to a path whose page-data.json was never generated (build failed for that page), the page resources loaded but the chunk threw an error (stored in pageResources.error), or a stale .cache directory has incomplete resources.
Common situations: A page threw an error during 'gatsby build' but the build partially succeeded; the .cache or public directory is corrupt or stale after a failed build; deploying incomplete build output; or a client-only route that was never created via createPage.
Related errors
- The following page component must contain '?__contentFilePat
- We couldn't find the correct component chunk with the name "
- We couldn't find the correct component chunk with the name "
AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13).
Data as JSON: /api/errors/387974e6774ba47f.
Report an issue: GitHub.