{"record":{"id":"332ac8f8b91d0ef7","repo":"slidevjs/slidev","slug":"failed-to-resolve-global-package-name","errorCode":null,"errorMessage":"Failed to resolve global package \"${name}\"","messagePattern":"Failed to resolve global package \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/slidev/node/resolver.ts","lineNumber":275,"sourceCode":"  const localPath = await findDepPkgJsonPath(name, cliRoot)\n  if (localPath)\n    return dirname(localPath)\n  for (const nm of invocationSearchPaths) {\n    const direct = join(nm, ...name.split('/'), 'package.json')\n    if (existsSync(direct))\n      return dirname(direct)\n    const walked = await findDepPkgJsonPath(name, nm)\n    if (walked)\n      return dirname(walked)\n  }\n  const yarnPath = join(globalDirs.yarn.packages, name)\n  if (existsSync(`${yarnPath}/package.json`))\n    return yarnPath\n  const npmPath = join(globalDirs.npm.packages, name)\n  if (existsSync(`${npmPath}/package.json`))\n    return npmPath\n  if (ensure)\n    throw new Error(`Failed to resolve global package \"${name}\"`)\n}\n\nexport async function resolveEntry(entryRaw: string) {\n  if (!existsSync(entryRaw) && !entryRaw.endsWith('.md') && !RE_PATH_SEPARATOR.test(entryRaw))\n    entryRaw += '.md'\n  const entry = resolve(entryRaw)\n  if (!existsSync(entry)) {\n    // Check if stdin is available for prompts (i.e., is a TTY)\n    if (!process.stdin.isTTY) {\n      console.error(`Entry file \"${entry}\" does not exist and cannot prompt for confirmation`)\n      process.exit(1)\n    }\n    const { create } = await prompts({\n      name: 'create',\n      type: 'confirm',\n      initial: 'Y',\n      message: `Entry file ${yellow(`\"${entry}\"`)} does not exist, do you want to create it?`,\n    })","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/slidevjs/slidev/blob/0d798ace5828966d9f77f62094d5f7a971ad98f7/packages/slidev/node/resolver.ts#L257-L293","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: theme missing from global install\nfindGlobalPkgRoot('@slidev/theme-seriph', true) // throws\n\n// after: install globally\n// shell:\nnpm i -g @slidev/theme-seriph","handlingStrategy":"try-catch","validationCode":"import globalDirs from 'global-directory'\nimport { existsSync } from 'node:fs'\nimport { join } from 'pathe'\n\nfunction globallyInstalled(name: string): boolean {\n  return existsSync(join(globalDirs.npm.packages, name, 'package.json'))\n    || existsSync(join(globalDirs.yarn.packages, name, 'package.json'))\n}\n\n// before findGlobalPkgRoot(name, true):\nif (!globallyInstalled(name)) {\n  throw new Error(`Install ${name} globally: npm i -g ${name}`)\n}","typeGuard":"function isGloballyInstalled(name: string): boolean {\n  return existsSync(join(globalDirs.npm.packages, name, 'package.json'))\n    || existsSync(join(globalDirs.yarn.packages, name, 'package.json'))\n}","tryCatchPattern":"try {\n  return await findGlobalPkgRoot(name, true)\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Failed to resolve global package ')) {\n    throw new Error(`${name} not installed globally; run npm i -g ${name}`)\n  }\n  throw e\n}","preventionTips":["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."],"tags":["resolver","global","dependencies","install"],"backgroundTag":null,"analyzedSha":"0d798ace5828966d9f77f62094d5f7a971ad98f7","analyzedAt":"2026-08-12T17:10:56.221Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}