Read and normalize the closest package.json file with helpful error handling.
read-package-up is a Node.js library that reads the closest package.json file in a directory hierarchy. It solves the problem of reliably locating and parsing project metadata by combining file discovery with error-handled JSON parsing and optional data normalization.
Node.js developers and tool authors who need to programmatically access package.json data from scripts, build tools, or CLI applications.
Developers choose read-package-up because it bundles finding, reading, and normalizing package.json into a single, robust utility with helpful errors, reducing manual file system logic and parsing issues.
Read the closest package.json file
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Walks up the directory tree to find the nearest package.json, eliminating manual path handling as described in the README's usage example.
Throws helpful JSON parsing errors with context for malformed package.json, improving debugging based on its integration with parse-json.
Normalizes package data using npm's standards by default, ensuring consistent structure for reliable processing in tools.
Provides both asynchronous and synchronous functions, accommodating different Node.js scripting needs, as shown in the API section.
Relies on external packages like find-up and parse-json, increasing the dependency tree and potential maintenance complexity.
Normalization is tied to npm conventions and cannot be easily customized, which might not suit projects with non-standard package.json structures.
Lacks caching mechanisms for repeated reads, which could lead to performance issues in tools that frequently access package.json.