stablyai/orca · error
Could not find package.json for ${packageName}
Error message
Could not find package.json for ${packageName} What it means
The `resolvePackageJsonPath` function successfully resolved the package's entry point via `require.resolve(packageName)` but then walked up the entire directory tree from that entry point without finding a package.json. This is an unusual state — every npm/pnpm package should have a package.json at its root. The walk goes from `dirname(entryPath)` up to the filesystem root.
Source
Thrown at config/packaged-runtime-node-modules.cjs:110
}
try {
return requireFromProject.resolve(`${packageName}/package.json`, { paths: [fromDir] })
} catch {
let entryPath
try {
entryPath = requireFromProject.resolve(packageName, { paths: [fromDir] })
} catch {
throw new Error(`Could not resolve package ${packageName} from ${fromDir}`)
}
let dir = dirname(entryPath)
while (dir !== dirname(dir)) {
const packageJsonPath = join(dir, 'package.json')
if (existsSync(packageJsonPath)) {
return packageJsonPath
}
dir = dirname(dir)
}
throw new Error(`Could not find package.json for ${packageName}`)
}
}
function readPackage(packageName, fromDir = projectDir) {
const packageJsonPath = resolvePackageJsonPath(packageName, fromDir)
const packageDir = realpathSync(dirname(packageJsonPath))
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'))
return {
name: packageJson.name ?? packageName,
packageDir,
dependencies: Object.keys(packageJson.dependencies ?? {})
}
}
function isKnownOmittedServeSimDependency(packageName, fromDir) {
if (packageName !== 'inspect-webkit') {
return false
}View on GitHub (pinned to 1136503c6a)
Solutions
- Check `entryPath` — log the resolved path to see where `require.resolve(packageName)` is pointing.
- If it's a pnpm symlink issue, verify the package's node_modules entry has its package.json: `ls node_modules/.pnpm/package@version/node_modules/package/package.json`.
- Reinstall the package: `pnpm install --force` to fix a corrupted install.
- If the package genuinely has no package.json (custom/internal), add one at its root directory.
Defensive patterns
Strategy: validation
Validate before calling
// Verify package.json exists at the package root
import { existsSync } from 'fs'
import { dirname, join } from 'path'
function findPackageJsonUpFrom(entryPath) {
let dir = dirname(entryPath)
while (dir !== dirname(dir)) {
if (existsSync(join(dir, 'package.json'))) return join(dir, 'package.json')
dir = dirname(dir)
}
return null
} Prevention
- Verify installs with `pnpm install --force` if you suspect corruption.
- Avoid manual deletion of package.json files in node_modules.
- For pnpm, check that symlinks in node_modules point to valid package directories in the .pnpm store.
When it happens
Trigger: A package whose main entry file is a standalone JS file not inside a package directory with a package.json. A symlink or monorepo setup where the resolved entry points outside the package's own directory. A corrupted or partial install where package.json was deleted but the entry file remains.
Common situations: pnpm symlink edge cases where `require.resolve` follows a symlink to a hoisted location outside the package directory. A package with a non-standard layout where the entry file is not under the package root. Manual file manipulation that deleted package.json. Very rare in practice.
Related errors
- Could not resolve package ${packageName} from ${fromDir}
- [plain-node-entry-guard] daemon-entry.js failed to load unde
- Packaged main bundle has bare runtime imports without copied
- package.json must declare bin.orca
- compiled CLI package boundary is missing: ${path.relative(pr
AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12).
Data as JSON: /api/errors/2ddc8e3de9b689ab.
Report an issue: GitHub.