Package Exports
- find-and-require-package-json
- find-and-require-package-json/esm/index.js
- find-and-require-package-json/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (find-and-require-package-json) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
find-and-require-package-json
Find the package.json file from within a build/package
This TypeScript module provides a function to locate, read, and parse the package.json file starting from a specified directory and searching up through parent directories.
install
npm install find-and-require-package-jsonExample
import { findAndRequirePackageJson } from 'find-and-require-package-json';
// Pass __dirname to find the package.json for your module
const packageJson = findAndRequirePackageJson(__dirname);
console.log('Package name:', packageJson.name);
console.log('Version:', packageJson.version);ESM Usage
For ESM modules, you'll need to convert import.meta.url to a directory path:
import { findAndRequirePackageJson } from 'find-and-require-package-json';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const packageJson = findAndRequirePackageJson(__dirname);Development
Setup
- Clone the repository:
git clone https://github.com/constructive-io/dev-utils.git- Install dependencies:
cd dev-utils
pnpm install
pnpm build- Test the package of interest:
cd packages/<packagename>
pnpm test:watchCredits
🛠 Built by the Constructive team — creators of modular Postgres tooling for secure, composable backends. If you like our work, contribute on GitHub.
Disclaimer
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.