pulumi/pulumi · error · Error

no package.json or package.yaml in ${dir}

Error message

no package.json or package.yaml in ${dir}

What it means

The manifest loader walks up from `startDir` looking for a `package.json` or `package.yaml` in the given directory. If neither exists in `dir`, it throws this error indicating no Node/package manifest was found where one was required.

Source

Thrown at sdk/nodejs/runtime/manifest.ts:52

    for (const name of PACKAGE_MANIFEST_NAMES) {
        const p = path.join(dir, name);
        let content: string;
        try {
            content = fs.readFileSync(p, { encoding: "utf-8" });
        } catch (err) {
            if ((err as NodeJS.ErrnoException).code === "ENOENT") {
                continue;
            }
            throw err;
        }
        try {
            const data = parseManifestContent(name, content);
            return { data, path: p };
        } catch (err) {
            throw new Error(`could not parse ${p}: ${(err as Error).message}`);
        }
    }
    throw new Error(`no package.json or package.yaml in ${dir}`);
}

/**
 * Walks up from `startDir` looking for the nearest directory containing a `package.json` or `package.yaml`. Returns the
 * path of the manifest file, or `undefined` if no manifest is found anywhere up the tree. If both files exist in the
 * same directory, `package.json` is preferred.
 *
 * @internal
 */
export function searchupPackageManifest(startDir: string): string | undefined {
    let dir = startDir;
    while (true) {
        for (const name of PACKAGE_MANIFEST_NAMES) {
            const p = path.join(dir, name);
            if (fs.existsSync(p)) {
                return p;
            }
        }

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Create a package.json in the program directory (`npm init -y` or `pulumi new`).
  2. Run the program from the directory containing the manifest.
  3. Add a package.yaml if you prefer YAML tooling.
  4. Check .gitignore/packaging rules so the manifest is present in the deployed/executed directory.

Example fix

// before: empty program dir
// after
$ cd my-program && npm init -y  # creates package.json
Defensive patterns

Strategy: validation

Validate before calling

const fs = require("fs");
if (!fs.existsSync("package.json") && !fs.existsSync("package.yaml")) {
  throw new Error("run from a directory containing package.json or package.yaml");
}

Try / catch

try {
  const manifest = await loadManifest(startDir);
} catch (err) {
  if ((err as Error).message.includes("no package.json or package.yaml")) {
    console.error("Initialize the project: npm init -y or pulumi new");
  }
  throw err;
}

Prevention

When it happens

Trigger: Running/serializing a program from a directory with no package.json or package.yaml at that level and the caller required a manifest (not a best-effort walk-up).

Common situations: Running pulumi from a subdirectory without ever creating package.json; deleted or gitignored manifest; executing from a temp/build directory that lacks the manifest; monorepo where only the root has a manifest but the tool needs one locally.

Related errors


AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31). Data as JSON: /api/errors/ca4bf68b7bc80f92. Report an issue: GitHub.