{"record":{"id":"5c8de60a1e74649c","repo":"JanDeDobbeleer/oh-my-posh","slug":"s-not-found-in-s","errorCode":null,"errorMessage":"%s not found in %s","messagePattern":"(.+?) not found in (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/segments/language.go","lineNumber":570,"sourceCode":"\t}\n\n\tdependencies, ok := packageData[\"dependencies\"].(map[string]any)\n\tif !ok {\n\t\treturn false\n\t}\n\n\tif _, exists := dependencies[name]; !exists {\n\t\treturn false\n\t}\n\n\treturn true\n}\n\nfunc (l *Language) nodePackageVersion(name string) (string, error) {\n\tfolder := filepath.Join(l.env.Pwd(), \"node_modules\", name)\n\n\tif !l.env.HasFilesInDir(folder, fileName) {\n\t\treturn \"\", fmt.Errorf(\"%s not found in %s\", fileName, folder)\n\t}\n\n\tcontent := l.env.FileContent(filepath.Join(folder, fileName))\n\tvar data ProjectData\n\terr := json.Unmarshal([]byte(content), &data)\n\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn data.Version, nil\n}\n","sourceCodeStart":552,"sourceCodeEnd":583,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/segments/language.go#L552-L583","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Run `npm install` (or yarn/pnpm install) in the project root so node_modules/<name> exists","cd to the directory that actually contains the dependency, or enable the segment only in the root","Verify the package is a direct dependency in package.json and not only hoisted elsewhere","If the segment is unwanted outside such projects, keep its Enabled check based on the presence of the files it needs"],"exampleFix":"// before\n$ cd sub-package && oh-my-posh print primary ...\n// error: package.json not found in .../sub-package/node_modules/foo\n// after\n$ npm install && oh-my-posh print primary ...","handlingStrategy":"validation","validationCode":"// check the dependency exists before enabling the segment\nif _, err := os.Stat(filepath.Join(pwd, \"node_modules\", \"foo\", \"package.json\")); err != nil {\n    // segment disabled or run npm install\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run npm/yarn/pnpm install after cloning","Enable node-based segments only in project roots","Don't clean node_modules in scripts that run before prompt rendering","Check the package is a declared direct dependency"],"tags":["go","node","filesystem","missing-file"],"backgroundTag":"file-not-found","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}