gatsbyjs/gatsby · error

${pluginName} created a slice and didn't pass the path to th

Error message

${pluginName} created a slice and didn't pass the path to the component

What it means

Thrown by createSlice when validateComponent returns an error for the slice component (no path / not absolute / does not exist / empty / no default export, codes 11333/11335/11336/11337/11338) and the error does not set panicOnBuild, so report.panic runs. Mirrors the createPage component validation but for slice components. Skipped when NODE_ENV==='test'.

Source

Thrown at packages/gatsby/src/redux/actions/restricted.ts:501

      const { slices } = store.getState()

      const { error, panicOnBuild } = validateComponent({
        input: payload,
        pluginName: name,
        errorIdMap: {
          noPath: `11333`,
          notAbsolute: `11335`,
          doesNotExist: `11336`,
          empty: `11337`,
          noDefaultExport: `11338`,
        },
      })

      if (error && process.env.NODE_ENV !== `test`) {
        if (panicOnBuild) {
          report.panicOnBuild(error)
        } else {
          report.panic(error)
        }
      }

      const componentPath = normalizePath(payload.component)

      const oldSlice = slices.get(payload.id)
      const contextModified =
        !!oldSlice && !isEqual(oldSlice.context, payload.context)
      const componentModified =
        !!oldSlice && !isEqual(oldSlice.componentPath, componentPath)

      return {
        type: `CREATE_SLICE`,
        plugin,
        payload: {
          componentChunkName: generateComponentChunkName(
            payload.component,
            `slice`

View on GitHub (pinned to 8b06340921)

Solutions

  1. Pass an absolute path via path.resolve for the slice component.
  2. Ensure the file exists with the exact casing used in code.
  3. Ensure the component file has a default export.
  4. Check the specific validateComponent error code (11333-11338) printed in the message for the precise failure.

Example fix

// before
actions.createSlice({ id: `header`, component: `./src/slices/header.js` })
// after
actions.createSlice({ id: `header`, component: path.resolve(`./src/slices/header.js`) })
// src/slices/header.js
export default () => <header>...</header>
Defensive patterns

Strategy: validation

Validate before calling

const path = require('path'), fs = require('fs')
const abs = path.isAbsolute(payload.component) ? payload.component : path.resolve(payload.component)
if (!fs.existsSync(abs)) throw new Error(`Slice component not found: ${abs}`)
actions.createSlice({ ...payload, component: abs })

Type guard

function isAbsoluteExistingSliceComponent(p: string): boolean {
  return typeof p === 'string' && path.isAbsolute(p) && require('fs').existsSync(p)
}

Prevention

When it happens

Trigger: payload.component fails validateComponent (missing, relative, non-existent, empty, or no default export) and panicOnBuild is false.

Common situations: Passing a relative path for the slice component; typo in filename; a slice component file with no default export; case mismatch surfaced by trueCasePathSync on Linux CI.

Related errors


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