{"record":{"id":"dad7e8e00460b33d","repo":"stablyai/orca","slug":"could-not-resolve-package-packagename-from-fr","errorCode":null,"errorMessage":"Could not resolve package ${packageName} from ${fromDir}","messagePattern":"Could not resolve package (.+?) from (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"config/packaged-runtime-node-modules.cjs","lineNumber":100,"sourceCode":"  if (existsSync(nested)) {\n    return nested\n  }\n  // Why: published serve-sim has no \".\" export (only ./middleware and ./state), so\n  // require.resolve('serve-sim') fails even though the package is present for bridge exec.\n  if (packageName === 'serve-sim') {\n    const direct = join(projectDir, 'node_modules', 'serve-sim', 'package.json')\n    if (existsSync(direct)) {\n      return direct\n    }\n  }\n  try {\n    return requireFromProject.resolve(`${packageName}/package.json`, { paths: [fromDir] })\n  } catch {\n    let entryPath\n    try {\n      entryPath = requireFromProject.resolve(packageName, { paths: [fromDir] })\n    } catch {\n      throw new Error(`Could not resolve package ${packageName} from ${fromDir}`)\n    }\n    let dir = dirname(entryPath)\n    while (dir !== dirname(dir)) {\n      const packageJsonPath = join(dir, 'package.json')\n      if (existsSync(packageJsonPath)) {\n        return packageJsonPath\n      }\n      dir = dirname(dir)\n    }\n    throw new Error(`Could not find package.json for ${packageName}`)\n  }\n}\n\nfunction readPackage(packageName, fromDir = projectDir) {\n  const packageJsonPath = resolvePackageJsonPath(packageName, fromDir)\n  const packageDir = realpathSync(dirname(packageJsonPath))\n  const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'))\n  return {","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/packaged-runtime-node-modules.cjs#L82-L118","documentation":"The `resolvePackageJsonPath` function tries to locate a package's package.json for the packaged runtime node_modules copy. It first checks `fromDir/node_modules/packageName/package.json`, then tries `require.resolve(packageName/package.json)`, then falls back to `require.resolve(packageName)` and walks up the directory tree. This error fires only when BOTH resolve calls fail — the package is not installed or not resolvable from the given directory.","triggerScenarios":"A package listed in PACKAGED_RUNTIME_PACKAGE_ROOTS (or one of its transitive dependencies) is not installed in node_modules. Running the packaging step from a directory where the package isn't resolvable. A package was removed from package.json but still listed in PACKAGED_RUNTIME_PACKAGE_ROOTS. pnpm hoisting differences where a dependency isn't at the expected path.","commonSituations":"Adding a package to PACKAGED_RUNTIME_PACKAGE_ROOTS without running `pnpm install`. A dependency that's optional and not installed on the current platform. pnpm symlink farm differences where `require.resolve` from the project root can't reach a hoisted dependency. Removing a package from package.json but forgetting to remove it from the roots list.","solutions":["Run `pnpm install` to ensure all packages in PACKAGED_RUNTIME_PACKAGE_ROOTS are installed.","If the package is optional/platform-specific, check if it's installed for the current platform. The parcel-watcher subpackage handling (lines 183-195) shows the pattern for optional deps."],"exampleFix":"// before — package removed from deps but still in roots\nconst PACKAGED_RUNTIME_PACKAGE_ROOTS = ['ws', 'yaml', 'removed-package']\n\n// after — remove from roots\nconst PACKAGED_RUNTIME_PACKAGE_ROOTS = ['ws', 'yaml']","handlingStrategy":"validation","validationCode":"// Verify all runtime package roots are installed before packaging\nimport { existsSync } from 'fs'\nimport { join } from 'path'\nconst ROOTS = ['@electron-toolkit/utils', '@linear/sdk', /* ...full list... */]\nfunction assertAllRootsInstalled(projectDir) {\n  const missing = ROOTS.filter(pkg => !existsSync(join(projectDir, 'node_modules', pkg, 'package.json')))\n  if (missing.length) {\n    throw new Error(`Missing packages — run pnpm install: ${missing.join(', ')}`)\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `pnpm install` before any packaging step.","When adding a package to PACKAGED_RUNTIME_PACKAGE_ROOTS, verify it's in package.json dependencies too.","For platform-specific optional deps, follow the parcel-watcher pattern (try/catch around visit at line 189)."],"tags":["packaging","node-modules","module-resolution","pnpm","runtime-deps"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}