{"record":{"id":"ea70a87d412fb6e6","repo":"pulumi/pulumi","slug":"did-not-find-package-json-or-package-yaml-in-s","errorCode":null,"errorMessage":"did not find package.json or package.yaml in %s: %w","messagePattern":"did not find package\\.json or package\\.yaml in (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdk/nodejs/npm/workspaces.go","lineNumber":47,"sourceCode":"// FindWorkspaceRoot determines if we are in a yarn/npm/pnpm workspace setup and\n// returns the root directory of the workspace.  If the startingPath is\n// not in a workspace, it returns ErrNotInWorkspace.\nfunc FindWorkspaceRoot(startingPath string) (string, error) {\n\tstat, err := os.Stat(startingPath)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif !stat.IsDir() {\n\t\tstartingPath = filepath.Dir(startingPath)\n\t}\n\t// We start at the location of the first package manifest we find. If there is no manifest\n\t// anywhere up the tree, the directory is not part of any project, much less a workspace.\n\tmanifestPath, err := SearchupPackageManifest(startingPath)\n\tif err != nil {\n\t\tif errors.Is(err, os.ErrNotExist) {\n\t\t\treturn \"\", ErrNotInWorkspace\n\t\t}\n\t\treturn \"\", fmt.Errorf(\"did not find package.json or package.yaml in %s: %w\", startingPath, err)\n\t}\n\tpackageJSONDir := filepath.Dir(manifestPath)\n\tcurrentDir := packageJSONDir\n\tnextDir := filepath.Dir(currentDir)\n\tfor currentDir != nextDir { // We're at the root when the nextDir is the same as the currentDir.\n\t\tp, err := findManifestInDir(currentDir)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tif p == \"\" {\n\t\t\t// No manifest in this directory, continue the search in the next directory up.\n\t\t\tcurrentDir = nextDir\n\t\t\tnextDir = filepath.Dir(currentDir)\n\t\t\tcontinue\n\t\t}\n\n\t\t// First look for pnpm workspace configuration\n\t\tpnpmWorkspace := filepath.Join(currentDir, \"pnpm-workspace.yaml\")","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/sdk/nodejs/npm/workspaces.go#L29-L65","documentation":"FindWorkspaceRoot could not locate a package.json or package.yaml in the starting directory or any parent, and the underlying error from SearchupPackageManifest was not simply os.ErrNotExist. The original error is wrapped and returned instead of the ErrNotInWorkspace sentinel.","triggerScenarios":"Calling FindWorkspaceRoot when SearchupPackageManifest fails with an error other than os.ErrNotExist (e.g. permission denied while walking directories, or a malformed path).","commonSituations":"Starting path points to an unreadable directory (permissions), startingPath contains invalid characters, or an ancestor directory denies traversal on Windows/network mounts.","solutions":["Check read/execute permissions on the starting directory and all ancestors","Confirm startingPath is a valid, absolute, existing directory path","Create a package.json in the project root so manifest search terminates normally","If it's a genuine 'no manifest' case, expect ErrNotInWorkspace instead — this wrapped error signals a deeper problem"],"exampleFix":"// before\nfindWorkspaceRoot(\"/root/private/project\")\n// after: ensure permissions\nchmod -R u+rx /root/private/project","handlingStrategy":"validation","validationCode":"const st = fs.statSync(startPath);\nif (!(st.isDirectory() && access ok)) throw new Error('startingPath must be a readable directory: ' + startPath);","typeGuard":null,"tryCatchPattern":"if err != nil { if errors.Is(err, os.ErrPermission) { /* fix perms or prompt user */ } return err }","preventionTips":["Ensure read+execute permissions on the starting directory and all ancestors","Pass absolute, existing directory paths to FindWorkspaceRoot","Commit a package.json at the repo root so upward search terminates quickly"],"tags":["workspace","filesystem","permissions","npm"],"backgroundTag":"manifest-lookup-failed","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}