{"record":{"id":"e2a379f5452981f4","repo":"gatsbyjs/gatsby","slug":"invalid-repl-directory-specified-directory","errorCode":null,"errorMessage":"Invalid REPL directory specified: \"${directory}\"","messagePattern":"Invalid REPL directory specified: \"(.+?)\"","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby-remark-code-repls/src/gatsby-node.js","lineNumber":28,"sourceCode":"  OPTION_DEFAULT_CODEPEN,\n} = require(`./constants`)\n\nexports.createPages = async (\n  { actions, reporter },\n  {\n    directory = OPTION_DEFAULT_REPL_DIRECTORY,\n    codepen = OPTION_DEFAULT_CODEPEN,\n  } = {}\n) => {\n  codepen = { ...OPTION_DEFAULT_CODEPEN, ...codepen }\n  if (!directory.endsWith(`/`)) {\n    directory += `/`\n  }\n\n  const { createPage } = actions\n\n  if (!fs.existsSync(directory)) {\n    reporter.panic(`Invalid REPL directory specified: \"${directory}\"`)\n  }\n\n  if (!fs.existsSync(codepen.redirectTemplate)) {\n    reporter.panic(\n      `Invalid REPL redirectTemplate specified: \"${codepen.redirectTemplate}\"`\n    )\n  }\n\n  try {\n    const files = await readdir(directory)\n    if (files.length === 0) {\n      console.warn(`Specified REPL directory \"${directory}\" contains no files`)\n\n      return\n    }\n\n    // escape backslashes for windows\n    const resolvedDirectory = resolve(directory)","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby-remark-code-repls/src/gatsby-node.js#L10-L46","documentation":"In gatsby-remark-code-repls createPages (gatsby-node.js:27-29), the plugin checks fs.existsSync(directory) after normalizing the directory option (defaulting to OPTION_DEFAULT_REPL_DIRECTORY, appending '/' if missing). If the directory does not exist on disk, reporter.panic fires. The directory is where the plugin looks for .js/.jsx files to create interactive CodePen REPL redirect pages.","triggerScenarios":"Configuring gatsby-remark-code-repls with a 'directory' option that doesn't exist. The default directory constant points to a path that hasn't been created. Typo in the directory path.","commonSituations":"Setting directory to a custom path that hasn't been created. Using the plugin without setting up the expected examples/examples directory. Path relative to cwd resolving to a non-existent location.","solutions":["Create the directory: mkdir -p <your-directory>","Verify the path: use an absolute path to avoid cwd ambiguity","Check for typos in the directory option"],"exampleFix":"// before: directory doesn't exist\noptions: { directory: `./src/examples` }\n// if ./src/examples doesn't exist → panic\n\n// after: create it first, or fix the path\nmkdir -p src/examples\n// or point to the correct existing path\noptions: { directory: `${__dirname}/src/examples` }","handlingStrategy":"validation","validationCode":"const fs = require('fs')\nconst path = require('path')\n\nconst replDirectory = path.resolve(process.cwd(), options.directory || './src/examples')\nif (!fs.existsSync(replDirectory)) {\n  throw new Error(`REPL directory does not exist: ${replDirectory}. Create it before building.`)\n}\nif (!fs.statSync(replDirectory).isDirectory()) {\n  throw new Error(`REPL path is not a directory: ${replDirectory}`)\n}","typeGuard":"import fs from 'fs'\nimport path from 'path'\n\nfunction isValidDirectory(dirPath: string): boolean {\n  const resolved = path.resolve(dirPath)\n  return fs.existsSync(resolved) && fs.statSync(resolved).isDirectory()\n}","tryCatchPattern":null,"preventionTips":["Create the examples directory before configuring the plugin","Use absolute paths for the directory option","Add directory existence checks to a pre-build script"],"tags":["configuration","filesystem","validation","code-repls"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}