{"record":{"id":"4f5201bea7daf7f1","repo":"gatsbyjs/gatsby","slug":"pagecreator-to-query-node-gatsbypath-the-filep-4f5201","errorCode":null,"errorMessage":"PageCreator: To query node \"gatsbyPath\" the \"filePath\" argument must represent a file that exists.\nUnable to find a file at: \"${absolutePath}\"","messagePattern":"PageCreator: To query node \"gatsbyPath\" the \"filePath\" argument must represent a file that exists\\.\nUnable to find a file at: \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/gatsby-plugin-page-creator/src/validate-path-query.ts","lineNumber":49,"sourceCode":"    )\n  }\n\n  const absolutePath = systemPath.join(process.cwd(), `src/pages`, filePath)\n\n  const file = _.flatten(\n    extensions.map(ext =>\n      [``, `${systemPath.sep}index`].map(index => {\n        try {\n          return require.resolve(absolutePath + index + ext)\n        } catch (e) {\n          return false\n        }\n      })\n    )\n  ).filter(Boolean) as Array<string>\n\n  if (file.length === 0 || file[0].length === 0) {\n    throw new Error(\n      `PageCreator: To query node \"gatsbyPath\" the \"filePath\" argument must represent a file that exists.\nUnable to find a file at: \"${absolutePath}\"`\n    )\n  }\n}\n","sourceCodeStart":31,"sourceCodeEnd":55,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby-plugin-page-creator/src/validate-path-query.ts#L31-L55","documentation":"validatePathQuery's final rule: after all syntactic checks pass, the resolver attempts require.resolve against absolutePath (process.cwd()/src/pages + filePath) across every configured extension and an optional /index suffix. If none resolves to a real file, the filePath does not correspond to anything on disk and the build fails with the absolute path it tried. This is the catch-all for logically-correct-but-nonexistent routes.","triggerScenarios":"Querying gatsbyPath for a filePath that points at a page that was never created: the file was deleted, renamed, not yet generated, or sits outside src/pages. Also fires when the extension of the file is not in the configured extensions list (e.g. a .vue file when gatsby is only configured for js/ts/mdx).","commonSituations":"Querying a route before creating the page; typos in the route segment; moving a file out of src/pages; using an extension gatsby-plugin-page-creator is not configured to pick up; race during incremental builds where the node is stale.","solutions":["Confirm a file exists at src/pages + filePath (the absolute path in the message) using ls.","If the file uses an unsupported extension, register it in gatsby-config.js via gatsby-plugin-page-creator options.extensions.","Re-run the build (gatsby clean && gatsby develop) to clear stale nodes if you recently added the file.","Fix typos in the route path - it must match the on-disk directory/filename exactly (minus extension and trailing index)."],"exampleFix":"// before: page does not exist\ngatsbyPath(filePath: \"/about-us\")\n// src/pages/about.js exists but not about-us\n\n// after: match an existing file\ngatsbyPath(filePath: \"/about\")","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nconst path = require('path');\nfunction resolvePageFile(filePath, extensions) {\n  const abs = path.join(process.cwd(), 'src/pages', filePath);\n  const found = extensions.flatMap(ext =>\n    ['', '/index'].map(idx => {\n      const candidate = abs + idx + ext;\n      return fs.existsSync(candidate) ? candidate : null;\n    })\n  ).filter(Boolean);\n  if (found.length === 0) {\n    throw new Error(`No page file found for ${filePath} at ${abs}`);\n  }\n  return found[0];\n}","typeGuard":"function pageFileExists(filePath, extensions) {\n  const abs = path.join(process.cwd(), 'src/pages', filePath);\n  return extensions.some(ext =>\n    ['', '/index'].some(idx => fs.existsSync(abs + idx + ext))\n  );\n}","tryCatchPattern":null,"preventionTips":["Run gatsby clean after adding new pages to avoid stale node state.","Ensure the page extension is registered in gatsby-plugin-page-creator options.extensions.","Unit-test dynamic filePath values against the filesystem before using them in queries."],"tags":["gatsby-plugin-page-creator","graphql","validation","gatsbypath","filesystem"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}