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

  1. Run `gatsby clean` to remove .cache and public, then rebuild.
  2. Check the build output for errors on the specific path — a page-level build error often leaves pageResources in an Error state.
  3. Verify the path exists in your site's generated pages (check public/page-data/ for the corresponding JSON).
  4. 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

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


AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13). Data as JSON: /api/errors/387974e6774ba47f. Report an issue: GitHub.