gatsbyjs/gatsby · error

It appears like Gatsby is misconfigured. JSONStore is Gatsby

Error message

It appears like Gatsby is misconfigured. JSONStore is Gatsby internal development-only component and should never be used in production.

Unless your site has a complex or custom webpack/Gatsby configuration this is likely a bug in Gatsby. Please report this at https://github.com/gatsbyjs/gatsby/issues with steps to reproduce this error.

What it means

Thrown at module evaluation time in query-result-store.js when process.env.NODE_ENV is 'production'. JSONStore is a development-only internal React component that reads static query results from the dev server; it must never ship in production bundles. If webpack includes this module in the production build, the module-level check fires immediately.

Source

Thrown at packages/gatsby/cache-dir/query-result-store.js:13

import React from "react"
import { StaticQueryContext } from "gatsby"
import {
  registerPath as socketRegisterPath,
  unregisterPath as socketUnregisterPath,
} from "./socketIo"
import PageRenderer from "./page-renderer"
import normalizePagePath from "./normalize-page-path"
import loader, { getStaticQueryResults, getSliceResults } from "./loader"
import { SlicesResultsContext } from "./slice/context"

if (process.env.NODE_ENV === `production`) {
  throw new Error(
    `It appears like Gatsby is misconfigured. JSONStore is Gatsby internal ` +
      `development-only component and should never be used in production.\n\n` +
      `Unless your site has a complex or custom webpack/Gatsby ` +
      `configuration this is likely a bug in Gatsby. ` +
      `Please report this at https://github.com/gatsbyjs/gatsby/issues ` +
      `with steps to reproduce this error.`
  )
}

const getPathFromProps = props =>
  props.pageResources && props.pageResources.page
    ? normalizePagePath(props.pageResources.page.path)
    : undefined

export class PageQueryStore extends React.Component {
  constructor(props) {
    super(props)
    this.state = {

View on GitHub (pinned to 8b06340921)

Solutions

  1. Run `gatsby clean` and rebuild to ensure a fresh production build.
  2. Remove or review custom webpack config in gatsby-node.js that might alter module resolution or DefinePlugin behavior.
  3. Verify NODE_ENV is set correctly: 'production' for `gatsby build`, 'development' for `gatsby develop`.
  4. Ensure all @gatsby packages are at compatible versions (check for version mismatches with `npm ls gatsby`).

Example fix

// before — custom webpack config interfering with dev/prod splitting
// gatsby-node.js
exports.onCreateWebpackConfig = ({ actions, stage }) => {
  actions.setWebpackConfig({
    optimization: { splitChunks: false }, // breaks dev/prod code splitting
  })
}

// after — don't override optimization settings that control dev-only inclusion
exports.onCreateWebpackConfig = ({ actions, stage }) => {
  // only add legitimate, non-breaking customizations
  actions.setWebpackConfig({
    resolve: { alias: { '@components': path.resolve('src/components') } },
  })
}
Defensive patterns

Strategy: validation

Validate before calling

// Verify NODE_ENV before building
if (process.env.NODE_ENV !== 'production') {
  console.warn('Building with NODE_ENV !== production may cause issues')
}
// Ensure consistent env:
// gatsby build sets NODE_ENV=production automatically
// gatsby develop sets NODE_ENV=development automatically

Prevention

When it happens

Trigger: The query-result-store.js module is evaluated in a production build context, meaning webpack did not exclude or tree-shake the dev-only code path. This is a Gatsby/webpack build configuration problem, not an application-level error.

Common situations: Custom webpack config that changes module resolution or optimization settings, a Gatsby version mismatch between packages, a plugin that forces dev-only modules into production bundles, or a misconfigured NODE_ENV (set to 'development' during build but 'production' at runtime, or vice versa).

Related errors


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