{"record":{"id":"43fced40773cdd45","repo":"remix-run/react-router","slug":"could-not-find-package-json-in-rootdirectory-or","errorCode":null,"errorMessage":"Could not find package.json in ${rootDirectory} or any of its parent directories. Please add a package.json, or provide a custom entry.server.tsx/jsx file in your app directory.","messagePattern":"Could not find package\\.json in (.+?) or any of its parent directories\\. Please add a package\\.json, or provide a custom entry\\.server\\.tsx/jsx file in your app directory\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-router-dev/config/config.ts","lineNumber":1047,"sourceCode":"  );\n\n  let userEntryClientFile = findEntry(appDirectory, \"entry.client\");\n  let userEntryServerFile = findEntry(appDirectory, \"entry.server\");\n\n  let entryServerFile: string;\n  let entryClientFile = userEntryClientFile || \"entry.client.tsx\";\n\n  if (userEntryServerFile) {\n    entryServerFile = userEntryServerFile;\n  } else {\n    let packageJsonPath = findEntry(rootDirectory, \"package\", {\n      extensions: [\".json\"],\n      absolute: true,\n      walkParents: true,\n    });\n\n    if (!packageJsonPath) {\n      throw new Error(\n        `Could not find package.json in ${rootDirectory} or any of its parent directories. Please add a package.json, or provide a custom entry.server.tsx/jsx file in your app directory.`,\n      );\n    }\n\n    let packageJsonDirectory = Path.dirname(packageJsonPath);\n    let pkgJson = await readPackageJSON(packageJsonDirectory);\n    let deps = pkgJson.dependencies ?? {};\n\n    if (!deps[\"isbot\"]) {\n      console.log(\n        \"adding `isbot@5` to your package.json, you should commit this change\",\n      );\n\n      await updatePackage(packageJsonPath, (pkg) => {\n        pkg.dependencies ??= {};\n        pkg.dependencies.isbot = \"^5\";\n        sortPackage(pkg);\n      });","sourceCodeStart":1029,"sourceCodeEnd":1065,"githubUrl":"https://github.com/remix-run/react-router/blob/6beaca39526d5716c3c112ebb0782765baa5a9ce/packages/react-router-dev/config/config.ts#L1029-L1065","documentation":"When the app has no custom entry.server file, resolveEntryFiles() walks rootDirectory and all parent directories looking for package.json: it reads dependencies to choose between the node and web default entry.server and to auto-install isbot if missing. If no package.json exists anywhere above the root, it throws this error suggesting either a package.json or a custom entry.server.","triggerScenarios":"Invoking @react-router/dev build/dev APIs with a rootDirectory that has no package.json above it (bare directory, deleted manifest, wrong root passed by a generator); unusual workspaces where the app root sits outside any package tree.","commonSituations":"Experimental setups and custom scaffolds calling the dev package programmatically; monorepo tooling misconfiguring the root directory; package.json accidentally removed.","solutions":["Add a package.json at the project root (npm init -y, then install react-router dependencies)","Or provide your own app/entry.server.tsx (or .jsx) so the default resolution and isbot check are skipped","Verify the rootDirectory passed to the tooling points at your React Router app package"],"exampleFix":"# before: bare directory, no manifest\nreact-router dev  # -> Could not find package.json ...\n\n# after: add a manifest and deps, or add app/entry.server.tsx\nnpm init -y && npm install react-router @react-router/dev @react-router/serve\n# or: create app/entry.server.tsx to bypass default resolution","handlingStrategy":"validation","validationCode":"import { existsSync } from \"node:fs\";\nimport path from \"node:path\";\n\nfunction hasPackageJsonAtOrAbove(dir: string): boolean {\n  let cur = path.resolve(dir);\n  for (;;) {\n    if (existsSync(path.join(cur, \"package.json\"))) return true;\n    const parent = path.dirname(cur);\n    if (parent === cur) return false;\n    cur = parent;\n  }\n}\n\nconst hasCustomEntryServer = [\"entry.server.tsx\", \"entry.server.jsx\"]\n  .some((f) => existsSync(path.join(appDirectory, f)));\n\nif (!hasPackageJsonAtOrAbove(rootDirectory) && !hasCustomEntryServer) {\n  throw new Error(\"Add a package.json above the app root, or provide app/entry.server.tsx\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always scaffold React Router apps inside a package with a package.json (create-react-router does this for you)","Provide a custom app/entry.server.tsx when you cannot guarantee a manifest above the root","When calling @react-router/dev programmatically, validate rootDirectory points at the app package"],"tags":["config","framework-mode","package-json","entry-server"],"backgroundTag":"missing-package-json","analyzedSha":"6beaca39526d5716c3c112ebb0782765baa5a9ce","analyzedAt":"2026-08-18T18:04:14.938Z","contentChangedAt":"2026-08-18T18:04:14.938Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}