refinedev/refine · error · Error

Package manager not found.

Error message

Package manager not found.

What it means

getPreferedPM uses the preferred-pm package to detect which package manager owns the current project (via lockfiles). If no npm/yarn/pnpm lockfile is found, it returns null and refine CLI throws this error before installing packages.

Source

Thrown at packages/cli/src/utils/package/index.ts:161

    outdatedJson: ["outdated", "--format", "json"],
    install: ["install"],
  },
  bun: {
    add: ["add"],
    addDev: ["add", "--dev"],
    outdatedJson: ["outdated", "--format", "json"],
    install: ["install"],
  },
};

export const getPreferedPM = async () => {
  const pm = await spinner(
    () => preferredPM(process.cwd()),
    "Getting package manager...",
  );

  if (!pm) {
    throw new Error("Package manager not found.");
  }

  return pm;
};

export const installPackages = async (
  packages: string[],
  type: "all" | "add" = "all",
  successMessage = "All `Refine` packages updated  🎉",
) => {
  const pm = await getPreferedPM();

  try {
    const installCommand =
      type === "all" ? pmCommands[pm.name].install : pmCommands[pm.name].add;

    const execution = execa(pm.name, [...installCommand, ...packages], {
      stdio: "inherit",

View on GitHub (pinned to 779d52a20e)

Solutions

  1. Run `npm install` (or yarn/pnpm install) once to generate a lockfile, then retry the CLI command
  2. If using bun, install the desired refine packages manually with `bun add`
  3. Ensure you're in the correct project directory containing the lockfile

Example fix

# before
refine add provider supabase   # no lockfile present
# after
npm install
refine add provider supabase
Defensive patterns

Strategy: validation

Validate before calling

const hasLock = ['package-lock.json','yarn.lock','pnpm-lock.yaml'].some(f => existsSync(f));
if (!hasLock) await installOnce(); // generate lockfile

Prevention

When it happens

Trigger: Running a refine CLI command that installs packages in a directory with no package-lock.json, yarn.lock, or pnpm-lock.md.

Common situations: Fresh directory with package.json created manually but no install run yet; lockfile deleted or gitignored; using a less common package manager (bun) not recognized by preferred-pm.

Related errors


AI-assisted analysis of refinedev/refine@779d52a20e (2026-08-27). Data as JSON: /api/errors/d4d7114eb564e368. Report an issue: GitHub.