{"record":{"id":"ca4bf68b7bc80f92","repo":"pulumi/pulumi","slug":"no-package-json-or-package-yaml-in-dir","errorCode":null,"errorMessage":"no package.json or package.yaml in ${dir}","messagePattern":"no package\\.json or package\\.yaml in (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"sdk/nodejs/runtime/manifest.ts","lineNumber":52,"sourceCode":"    for (const name of PACKAGE_MANIFEST_NAMES) {\n        const p = path.join(dir, name);\n        let content: string;\n        try {\n            content = fs.readFileSync(p, { encoding: \"utf-8\" });\n        } catch (err) {\n            if ((err as NodeJS.ErrnoException).code === \"ENOENT\") {\n                continue;\n            }\n            throw err;\n        }\n        try {\n            const data = parseManifestContent(name, content);\n            return { data, path: p };\n        } catch (err) {\n            throw new Error(`could not parse ${p}: ${(err as Error).message}`);\n        }\n    }\n    throw new Error(`no package.json or package.yaml in ${dir}`);\n}\n\n/**\n * Walks up from `startDir` looking for the nearest directory containing a `package.json` or `package.yaml`. Returns the\n * path of the manifest file, or `undefined` if no manifest is found anywhere up the tree. If both files exist in the\n * same directory, `package.json` is preferred.\n *\n * @internal\n */\nexport function searchupPackageManifest(startDir: string): string | undefined {\n    let dir = startDir;\n    while (true) {\n        for (const name of PACKAGE_MANIFEST_NAMES) {\n            const p = path.join(dir, name);\n            if (fs.existsSync(p)) {\n                return p;\n            }\n        }","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/sdk/nodejs/runtime/manifest.ts#L34-L70","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Create a package.json in the program directory (`npm init -y` or `pulumi new`).","Run the program from the directory containing the manifest.","Add a package.yaml if you prefer YAML tooling.","Check .gitignore/packaging rules so the manifest is present in the deployed/executed directory."],"exampleFix":"// before: empty program dir\n// after\n$ cd my-program && npm init -y  # creates package.json","handlingStrategy":"validation","validationCode":"const fs = require(\"fs\");\nif (!fs.existsSync(\"package.json\") && !fs.existsSync(\"package.yaml\")) {\n  throw new Error(\"run from a directory containing package.json or package.yaml\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  const manifest = await loadManifest(startDir);\n} catch (err) {\n  if ((err as Error).message.includes(\"no package.json or package.yaml\")) {\n    console.error(\"Initialize the project: npm init -y or pulumi new\");\n  }\n  throw err;\n}","preventionTips":["Run pulumi commands from the project root that contains the manifest","Ensure package.json is committed and not excluded by packaging rules","Create manifests with `pulumi new` or `npm init` before running programs"],"tags":["manifest","package-json","project-setup"],"backgroundTag":"missing-package-json","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}