Budibase/budibase · error

Please run in a plugin directory - must contain package.json

Error message

Please run in a plugin directory - must contain package.json

What it means

checkInPlugin is a guard used by the Budibase CLI plugin commands (verify, migrateSvelte5). It insists the current working directory is a plugin project by checking that package.json exists. If not, it throws so the command cannot run against an unrelated directory.

Source

Thrown at packages/cli/src/plugins/index.ts:52

      continue
    }
    try {
      fs.unlinkSync(p)
      deleted.push(p)
    } catch (err: any) {
      failed.push({
        path: p,
        error: err instanceof Error ? err.message : String(err),
      })
    }
  }

  return { deleted, failed }
}

function checkInPlugin() {
  if (!fs.existsSync("package.json")) {
    throw new Error(
      "Please run in a plugin directory - must contain package.json"
    )
  }
  if (!fs.existsSync("schema.json")) {
    throw new Error(
      "Please run in a plugin directory - must contain schema.json"
    )
  }
}

async function askAboutTopLevel(name: string) {
  const files = fs.readdirSync(process.cwd())
  // we are in an empty git repo, don't ask
  if (files.find(file => file === ".git")) {
    return false
  } else {
    console.log(
      info(`By default the plugin will be created in the directory "${name}"`)

View on GitHub (pinned to a81a902e9a)

Solutions

  1. cd into the plugin's root directory (the one containing package.json and schema.json) and re-run the command
  2. If the directory is not yet a plugin, scaffold one with the plugin init command so package.json is generated
  3. Run `ls package.json` to confirm your working directory before invoking the CLI

Example fix

// before (wrong dir)
~/projects $ budibase-plugins verify
// Error: Please run in a plugin directory - must contain package.json
// after
cd ~/projects/my-budi-plugin && budibase-plugins verify
Defensive patterns

Strategy: validation

Validate before calling

import fs from "fs"
if (!fs.existsSync("package.json")) {
  throw new Error("Not a plugin directory: package.json missing. Run from the plugin root.")
}

Type guard

const isPluginDir = (dir: string = process.cwd()): boolean =>
  fs.existsSync(`${dir}/package.json`) && fs.existsSync(`${dir}/schema.json`)

Prevention

When it happens

Trigger: Running `budibase-plugins verify` or `budibase-plugins migrateSvelte5` from a directory where fs.existsSync("package.json") is false — i.e. not at the root of a plugin project.

Common situations: Running the CLI from the repo root or home directory instead of the plugin folder; running inside a subdirectory of the plugin (e.g. src/) that has no package.json; a plugin scaffolded before package.json was created; a typo'd cd.

Related errors


AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/85c70dbf4761ff87. Report an issue: GitHub.