Man page - npm-query(1)
Packages contas this manual
- npm-explain(1)
- npm-star(1)
- npm-logout(1)
- npm-arborist(1)
- package-lock-json(5)
- npm-bugs(1)
- npm-shrinkwrap(1)
- npm-dist-tag(1)
- npm-login(1)
- npm-whoami(1)
- npm-doctor(1)
- npm-install(1)
- npm-run-script(1)
- npm-exec(1)
- npm-repo(1)
- npm-docs(1)
- npm-shrinkwrap-json(5)
- npm-edit(1)
- npm-stop(1)
- npm-diff(1)
- npm-find-dupes(1)
- npm-profile(1)
- npm-start(1)
- pacote(1)
- npm-ci(1)
- npm-stars(1)
- npm-update(1)
- npm-ping(1)
- npm-pack(1)
- npm-help-search(1)
- npm-prune(1)
- npm-org(1)
- npmrc(5)
- npm-audit(1)
- npm-unstar(1)
- arborist(1)
- npm-prefix(1)
- npm-publish(1)
- npm-config(1)
- npm-pkg(1)
- npm-adduser(1)
- npm-version(1)
- npm-completion(1)
- npm-install-test(1)
- npm-uninstall(1)
- npm-team(1)
- npm-help(1)
- npm-install-ci-test(1)
- npm-cache(1)
- npm-explore(1)
- npm-link(1)
- npm-root(1)
- package-json(5)
- npm-dedupe(1)
- npm-rebuild(1)
- npm-hook(1)
- npm-ls(1)
- npm-unpublish(1)
- npm-init(1)
- npm-restart(1)
- npm-outdated(1)
- npx(1)
- npm-access(1)
- npm-deprecate(1)
- npm-fund(1)
- npm-query(1)
- npm-owner(1)
- npm-test(1)
- npm-search(1)
- npm-token(1)
- npm-view(1)
- npm(1)
- node-npmcli-package-json
- node-libnpmpublish
- node-libnpmhook
- node-npm-packlist
- node-npmcli-installed-package-contents
- node-libnpmorg
- node-libnpmsearch
- node-npmcli-arborist
- node-npmcli-metavuln-calculator
- node-npmcli-mock-registry
- node-npmcli-disparity-colors
- node-npmcli-config
- node-pacote
- node-libnpmpack
- node-npmcli-map-workspaces
- node-libnpmaccess
- npm
- node-npmcli-smoke-tests
- node-libnpmversion
- node-npmcli-query
- node-libnpmteam
- node-npmcli-name-from-folder
- node-libnpmfund
- node-npmcli-promise-spawn
- node-libnpmdiff
- node-npmcli-run-script
- node-qrcode-terminal
- node-npmcli-node-gyp
- node-npmcli-git
- node-libnpmexec
Package: npm
apt-get install npm
apt-get install npm
Manuals in package:
Documentations in package:
Manual
| NPM-QUERY(1) | General Commands Manual | NPM-QUERY(1) |
NAME
npm-query
Synopsis
<!-- AUTOGENERATED USAGE DESCRIPTIONS -->
Description
The npm query command allows for usage of css selectors in
order to retrieve
an array of dependency objects.
Piping npm query to other commands
# find all dependencies with postinstall scripts & uninstall them
npm query ":attr(scripts, [postinstall])" | jq 'map(.name)|join("\n")' -r | xargs -I {} npm uninstall {}
# find all git dependencies & explain who requires them
npm query ":type(git)" | jq 'map(.name)' | xargs -I {} npm why {}
Extended Use Cases & Queries
// all deps * // all direct deps :root > * // direct production deps :root > .prod // direct development deps :root > .dev // any peer dep of a direct deps :root > * > .peer // any workspace dep .workspace // all workspaces that depend on another workspace .workspace > .workspace // all workspaces that have peer deps .workspace:has(.peer) // any dep named "lodash" // equivalent to [name="lodash"] #lodash // any deps named "lodash" & within semver range ^"1.2.3" #lodash@^1.2.3 // equivalent to... [name="lodash"]:semver(^1.2.3) // get the hoisted node for a given semver range #lodash@^1.2.3:not(:deduped) // querying deps with a specific version #lodash@2.1.5 // equivalent to... [name="lodash"][version="2.1.5"] // has any deps :has(*) // deps with no other deps (ie. "leaf" nodes) :empty // manually querying git dependencies [repository^=github:], [repository^=git:], [repository^=https://github.com], [repository^=http://github.com], [repository^=https://github.com], [repository^=+git:...] // querying for all git dependencies :type(git) // get production dependencies that aren't also dev deps .prod:not(.dev) // get dependencies with specific licenses [license=MIT], [license=ISC] // find all packages that have @ruyadorno as a contributor :attr(contributors, [email=ruyadorno@github.com])
Example Response Output
- •
- an array of dependency objects is returned which can contain multiple copies of the same package which may or may not have been linked or deduped
[
{
"name": "",
"version": "",
"description": "",
"homepage": "",
"bugs": {},
"author": {},
"license": {},
"funding": {},
"files": [],
"main": "",
"browser": "",
"bin": {},
"man": [],
"directories": {},
"repository": {},
"scripts": {},
"config": {},
"dependencies": {},
"devDependencies": {},
"optionalDependencies": {},
"bundledDependencies": {},
"peerDependencies": {},
"peerDependenciesMeta": {},
"engines": {},
"os": [],
"cpu": [],
"workspaces": {},
"keywords": [], ...
}, ...
Configuration
<!-- AUTOGENERATED CONFIG DESCRIPTIONS -->
See Also
- •
- dependency selectors
| May 2024 | 9.2.0 |