slidevjs/slidev · critical · Error
Failed to resolve global package "${name}"
Error message
Failed to resolve global package "${name}" What it means
Thrown by findGlobalPkgRoot(name, ensure: true) when none of the resolution paths yield the package: not in the cli's own node_modules, not in any invocation search path, not in yarn global packages, not in npm global packages. The ensure: true overload returns a string or throws.
Source
Thrown at packages/slidev/node/resolver.ts:275
const localPath = await findDepPkgJsonPath(name, cliRoot)
if (localPath)
return dirname(localPath)
for (const nm of invocationSearchPaths) {
const direct = join(nm, ...name.split('/'), 'package.json')
if (existsSync(direct))
return dirname(direct)
const walked = await findDepPkgJsonPath(name, nm)
if (walked)
return dirname(walked)
}
const yarnPath = join(globalDirs.yarn.packages, name)
if (existsSync(`${yarnPath}/package.json`))
return yarnPath
const npmPath = join(globalDirs.npm.packages, name)
if (existsSync(`${npmPath}/package.json`))
return npmPath
if (ensure)
throw new Error(`Failed to resolve global package "${name}"`)
}
export async function resolveEntry(entryRaw: string) {
if (!existsSync(entryRaw) && !entryRaw.endsWith('.md') && !RE_PATH_SEPARATOR.test(entryRaw))
entryRaw += '.md'
const entry = resolve(entryRaw)
if (!existsSync(entry)) {
// Check if stdin is available for prompts (i.e., is a TTY)
if (!process.stdin.isTTY) {
console.error(`Entry file "${entry}" does not exist and cannot prompt for confirmation`)
process.exit(1)
}
const { create } = await prompts({
name: 'create',
type: 'confirm',
initial: 'Y',
message: `Entry file ${yellow(`"${entry}"`)} does not exist, do you want to create it?`,
})View on GitHub (pinned to 0d798ace58)
Solutions
- Install the package globally: npm i -g <name> (or yarn global add <name>).
- Verify the global packages directory matches what Slidev scans: check npm config get prefix and yarn global dir.
- For pnpm globals, ensure PNPM_HOME is set and the v11 layout is intact.
- Prefer running Slidev project-locally so the dependency resolves from node_modules instead of global paths.
Example fix
// before: theme missing from global install
findGlobalPkgRoot('@slidev/theme-seriph', true) // throws
// after: install globally
// shell:
npm i -g @slidev/theme-seriph Defensive patterns
Strategy: try-catch
Validate before calling
import globalDirs from 'global-directory'
import { existsSync } from 'node:fs'
import { join } from 'pathe'
function globallyInstalled(name: string): boolean {
return existsSync(join(globalDirs.npm.packages, name, 'package.json'))
|| existsSync(join(globalDirs.yarn.packages, name, 'package.json'))
}
// before findGlobalPkgRoot(name, true):
if (!globallyInstalled(name)) {
throw new Error(`Install ${name} globally: npm i -g ${name}`)
} Type guard
function isGloballyInstalled(name: string): boolean {
return existsSync(join(globalDirs.npm.packages, name, 'package.json'))
|| existsSync(join(globalDirs.yarn.packages, name, 'package.json'))
} Try / catch
try {
return await findGlobalPkgRoot(name, true)
} catch (e) {
if (e instanceof Error && e.message.startsWith('Failed to resolve global package ')) {
throw new Error(`${name} not installed globally; run npm i -g ${name}`)
}
throw e
} Prevention
- Install globally-required themes/addons with npm i -g <name>.
- Verify npm/yarn global prefix matches the directories Slidev scans.
- For pnpm globals, keep PNPM_HOME set and the v11 layout intact.
- Prefer project-local installs to avoid global-resolution fragility.
When it happens
Trigger: Calling findGlobalPkgRoot(name, true) for a package that is not installed globally and not bundled with the cli. Reached when Slidev runs globally and a required global dependency is absent.
Common situations: Global Slidev install missing a globally-required theme/addon/plugin; PNPM_HOME/npm global prefix misconfigured so global packages aren't where the code looks; yarn vs npm global layout mismatch.
Related errors
- Failed to resolve package "${importName}"
- Failed to resolve package "${dep}"
- Invalid ${type} name "${name}". Only valid npm package names
- [slidev] Cannot find roots without entry
AI-assisted analysis of slidevjs/slidev@0d798ace58 (2026-08-12).
Data as JSON: /api/errors/332ac8f8b91d0ef7.
Report an issue: GitHub.