gatsbyjs/gatsby · error

gatsby-plugin-page-creator_12108

gatsby-plugin-page-creator_12108

Error message

The path passed to gatsby-plugin-page-creator does not exist on your file system:

${pagesPath}

Please pick a path to an existing directory.

What it means

In gatsby-node.ts:87-97, after confirming pagesPath is truthy, the plugin checks if pathCheck is true (default) AND the directory does not exist via !existsSync(pagesPath). If the resolved path doesn't correspond to a real directory on disk, reporter.panic fires with id CODES.NonExistingPath. The path is resolved relative to process.cwd() at line 99.

Source

Thrown at packages/gatsby-plugin-page-creator/src/gatsby-node.ts:88

    const { program, config } = store.getState()
    const { trailingSlash = `always` } = config

    const exts = program.extensions.map(e => `${e.slice(1)}`).join(`,`)

    if (!pagesPath) {
      reporter.panic({
        id: prefixId(CODES.RequiredPath),
        context: {
          sourceMessage: `"path" is a required option for gatsby-plugin-page-creator

See docs here - https://www.gatsbyjs.com/plugins/gatsby-plugin-page-creator/`,
        },
      })
    }

    // Validate that the path exists.
    if (pathCheck && !existsSync(pagesPath)) {
      reporter.panic({
        id: prefixId(CODES.NonExistingPath),
        context: {
          sourceMessage: `The path passed to gatsby-plugin-page-creator does not exist on your file system:

${pagesPath}

Please pick a path to an existing directory.`,
        },
      })
    }

    const pagesDirectory = systemPath.resolve(process.cwd(), pagesPath)
    const pagesGlob = `**/*.{${exts}}`

    // Get initial list of files.
    const files = await glob(pagesGlob, { cwd: pagesPath })
    files.forEach(file => {
      createPage(

View on GitHub (pinned to 8b06340921)

Solutions

  1. Verify the directory exists: ls -la <your-path>
  2. Use an absolute path via __dirname: path: `${__dirname}/src/pages`
  3. Create the missing directory if needed: mkdir -p src/pages
  4. Set pathCheck: false only if you intentionally want to skip existence validation (not recommended)

Example fix

// before
options: { path: `./src/page` } // typo — directory doesn't exist

// after
options: { path: `${__dirname}/src/pages` }
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs')
const path = require('path')

const pagesPath = path.resolve(process.cwd(), options.path)
if (!fs.existsSync(pagesPath)) {
  throw new Error(`Directory does not exist: ${pagesPath}`)
}
if (!fs.statSync(pagesPath).isDirectory()) {
  throw new Error(`Path is not a directory: ${pagesPath}`)
}

Type guard

import fs from 'fs'
import path from 'path'

function isValidPagesDirectory(p: string): boolean {
  const resolved = path.resolve(process.cwd(), p)
  return fs.existsSync(resolved) && fs.statSync(resolved).isDirectory()
}

Prevention

When it happens

Trigger: Providing a path option that points to a non-existent directory. Typo in the path string. Wrong relative path (path is resolved relative to cwd, not __dirname of gatsby-config). Directory was deleted or never created.

Common situations: Path typo (e.g. 'src/page' instead of 'src/pages'). Using a relative path that resolves differently than expected. Referencing a directory that hasn't been created yet. Moving project files without updating config.

Related errors


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