JanDeDobbeleer/oh-my-posh · warning

%s not found in %s

Error message

%s not found in %s

What it means

The node package version lookup expects `<pwd>/node_modules/<name>/<fileName>` (a package.json-style file) to exist. When the environment reports no such file in the package directory, the segment returns '%s not found in %s' naming the file and folder.

Source

Thrown at src/segments/language.go:570

	}

	dependencies, ok := packageData["dependencies"].(map[string]any)
	if !ok {
		return false
	}

	if _, exists := dependencies[name]; !exists {
		return false
	}

	return true
}

func (l *Language) nodePackageVersion(name string) (string, error) {
	folder := filepath.Join(l.env.Pwd(), "node_modules", name)

	if !l.env.HasFilesInDir(folder, fileName) {
		return "", fmt.Errorf("%s not found in %s", fileName, folder)
	}

	content := l.env.FileContent(filepath.Join(folder, fileName))
	var data ProjectData
	err := json.Unmarshal([]byte(content), &data)

	if err != nil {
		return "", err
	}

	return data.Version, nil
}

View on GitHub (pinned to 0976794618)

Solutions

  1. Run `npm install` (or yarn/pnpm install) in the project root so node_modules/<name> exists
  2. cd to the directory that actually contains the dependency, or enable the segment only in the root
  3. Verify the package is a direct dependency in package.json and not only hoisted elsewhere
  4. If the segment is unwanted outside such projects, keep its Enabled check based on the presence of the files it needs

Example fix

// before
$ cd sub-package && oh-my-posh print primary ...
// error: package.json not found in .../sub-package/node_modules/foo
// after
$ npm install && oh-my-posh print primary ...
Defensive patterns

Strategy: validation

Validate before calling

// check the dependency exists before enabling the segment
if _, err := os.Stat(filepath.Join(pwd, "node_modules", "foo", "package.json")); err != nil {
    // segment disabled or run npm install
}

Prevention

When it happens

Trigger: Rendering a node/package-dependent segment (e.g. an Nx or node workspace segment) while the working directory has no node_modules/<name> folder, or node_modules was deleted/not yet installed.

Common situations: Fresh clone before `npm install`; dependencies hoisted to a monorepo root while the prompt runs in a sub-package; .gitignore'd node_modules removed by a clean script; wrong cwd (prompt in a directory that isn't the JS project root).

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31). Data as JSON: /api/errors/5c8de60a1e74649c. Report an issue: GitHub.