stablyai/orca · critical
Could not resolve package ${packageName} from ${fromDir}
Error message
Could not resolve package ${packageName} from ${fromDir} What it means
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.
Source
Thrown at config/packaged-runtime-node-modules.cjs:100
if (existsSync(nested)) {
return nested
}
// Why: published serve-sim has no "." export (only ./middleware and ./state), so
// require.resolve('serve-sim') fails even though the package is present for bridge exec.
if (packageName === 'serve-sim') {
const direct = join(projectDir, 'node_modules', 'serve-sim', 'package.json')
if (existsSync(direct)) {
return direct
}
}
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 {View on GitHub (pinned to 1136503c6a)
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.
Example fix
// before — package removed from deps but still in roots const PACKAGED_RUNTIME_PACKAGE_ROOTS = ['ws', 'yaml', 'removed-package'] // after — remove from roots const PACKAGED_RUNTIME_PACKAGE_ROOTS = ['ws', 'yaml']
Defensive patterns
Strategy: validation
Validate before calling
// Verify all runtime package roots are installed before packaging
import { existsSync } from 'fs'
import { join } from 'path'
const ROOTS = ['@electron-toolkit/utils', '@linear/sdk', /* ...full list... */]
function assertAllRootsInstalled(projectDir) {
const missing = ROOTS.filter(pkg => !existsSync(join(projectDir, 'node_modules', pkg, 'package.json')))
if (missing.length) {
throw new Error(`Missing packages — run pnpm install: ${missing.join(', ')}`)
}
} Prevention
- 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).
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Could not find package.json for ${packageName}
- Packaged main bundle has bare runtime imports without copied
- [plain-node-entry-guard] daemon-entry.js failed to load unde
- Missing packaged resources directory: ${resourcesDir}
- Unsupported local-build compatibility architecture: ${contex
AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12).
Data as JSON: /api/errors/dad7e8e00460b33d.
Report an issue: GitHub.