which-npm
v1.0.1
Published
A command-line utility that helps you locate the package.json file that a specific file or directory belongs to
Maintainers
Readme
which-npm
which-npm is a command-line utility that helps you locate the package.json file that a specific file or directory belongs to.
Installation
npm install -g which-npm
# or simply run through npx
npx which-npmUsage
# If no path is provided, the current working directory is used.
which-npm [path] [options]Examples
Basic usage (displays package name):
which-npm
# my-awesome-packageShow the absolute path to the package.json file:
which-npm -p
# /Users/username/projects/my-awesome-package/package.jsonShow the relative path from ./dist/index.js to the package.json file:
which-npm ./dist/index.js --path-relative
# ../package.jsonDisplay the entire package.json content:
which-npm --json
# { "name": "my-awesome-package", "version": "1.0.0", ... }Recursively find all parent package.json files:
which-npm -r
# my-awesome-package
# parent-workspace
# root-projectOptions
For a full list of options, run:
which-npm --helpUse Cases
- Identify which package a file belongs to in monorepos and print the package name, path or json content
- Find the nearest
package.jsonwhen working in deeply nested directories
License
MIT
