pulumi/pulumi · error
did not find package.json or package.yaml in %s: %w
Error message
did not find package.json or package.yaml in %s: %w
What it means
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.
Source
Thrown at sdk/nodejs/npm/workspaces.go:47
// FindWorkspaceRoot determines if we are in a yarn/npm/pnpm workspace setup and
// returns the root directory of the workspace. If the startingPath is
// not in a workspace, it returns ErrNotInWorkspace.
func FindWorkspaceRoot(startingPath string) (string, error) {
stat, err := os.Stat(startingPath)
if err != nil {
return "", err
}
if !stat.IsDir() {
startingPath = filepath.Dir(startingPath)
}
// We start at the location of the first package manifest we find. If there is no manifest
// anywhere up the tree, the directory is not part of any project, much less a workspace.
manifestPath, err := SearchupPackageManifest(startingPath)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
return "", ErrNotInWorkspace
}
return "", fmt.Errorf("did not find package.json or package.yaml in %s: %w", startingPath, err)
}
packageJSONDir := filepath.Dir(manifestPath)
currentDir := packageJSONDir
nextDir := filepath.Dir(currentDir)
for currentDir != nextDir { // We're at the root when the nextDir is the same as the currentDir.
p, err := findManifestInDir(currentDir)
if err != nil {
return "", err
}
if p == "" {
// No manifest in this directory, continue the search in the next directory up.
currentDir = nextDir
nextDir = filepath.Dir(currentDir)
continue
}
// First look for pnpm workspace configuration
pnpmWorkspace := filepath.Join(currentDir, "pnpm-workspace.yaml")View on GitHub (pinned to 793f7b2e16)
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
Example fix
// before
findWorkspaceRoot("/root/private/project")
// after: ensure permissions
chmod -R u+rx /root/private/project Defensive patterns
Strategy: validation
Validate before calling
const st = fs.statSync(startPath);
if (!(st.isDirectory() && access ok)) throw new Error('startingPath must be a readable directory: ' + startPath); Try / catch
if err != nil { if errors.Is(err, os.ErrPermission) { /* fix perms or prompt user */ } return err } Prevention
- 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
When it happens
Trigger: Calling FindWorkspaceRoot when SearchupPackageManifest fails with an error other than os.ErrNotExist (e.g. permission denied while walking directories, or a malformed path).
Common situations: Starting path points to an unreadable directory (permissions), startingPath contains invalid characters, or an ancestor directory denies traversal on Windows/network mounts.
Related errors
- creating plugin root: %w
- getting current working directory: %w
- Could not locate an executable pulumi-watch, found %v withou
- removing undecryptable credentials: %w
- creating cache dir: %w
AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31).
Data as JSON: /api/errors/ea70a87d412fb6e6.
Report an issue: GitHub.