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
- Pass an absolute path via path.resolve for the slice component.
- Ensure the file exists with the exact casing used in code.
- Ensure the component file has a default export.
- 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
- Always resolve slice component paths to absolute.
- Match file casing exactly (case-sensitive on Linux CI).
- Ensure each slice component has a default export.
- Guard createSlice calls behind an existence check during dynamic generation.
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
- ${pluginName} must set the absolute path to the page compone
- 11334
- 11322
- The prop `fluid` or `fixed` is marked as required in `${comp
- ${JSON.stringify(result)}
AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13).
Data as JSON: /api/errors/57a86211d6dd3926.
Report an issue: GitHub.