Man page - npm-query(1)
Packages contains this manual
- npm-root(1)
- npm-explain(1)
- npm-whoami(1)
- npm-pack(1)
- npm-bugs(1)
- npm-view(1)
- npm-outdated(1)
- npm-update(1)
- npm-query(1)
- npm-logout(1)
- npm-deprecate(1)
- npm-exec(1)
- npm-ping(1)
- npm-shrinkwrap-json(5)
- npm-help(1)
- npm-prefix(1)
- npm-diff(1)
- npm-owner(1)
- npm-install(1)
- npmrc(5)
- npm-uninstall(1)
- npm-hook(1)
- npm-unstar(1)
- npm-docs(1)
- pacote(1)
- npm-restart(1)
- npm-star(1)
- npm-link(1)
- npm-test(1)
- npm-token(1)
- npm-arborist(1)
- npm-profile(1)
- npm-team(1)
- npx(1)
- npm-stars(1)
- npm-adduser(1)
- npm-cache(1)
- npm-edit(1)
- npm-doctor(1)
- npm-help-search(1)
- arborist(1)
- npm-rebuild(1)
- npm-repo(1)
- npm-publish(1)
- npm-start(1)
- npm-unpublish(1)
- npm-dedupe(1)
- npm-init(1)
- npm-dist-tag(1)
- npm-login(1)
- npm-config(1)
- npm(1)
- npm-search(1)
- npm-version(1)
- npm-org(1)
- npm-shrinkwrap(1)
- npm-ls(1)
- package-json(5)
- npm-stop(1)
- npm-install-test(1)
- npm-completion(1)
- npm-run-script(1)
- npm-prune(1)
- npm-access(1)
- npm-ci(1)
- npm-audit(1)
- npm-find-dupes(1)
- npm-install-ci-test(1)
- package-lock-json(5)
- npm-fund(1)
- npm-explore(1)
- npm-pkg(1)
- node-pacote
- node-npmcli-mock-registry
- node-npmcli-node-gyp
- node-libnpmorg
- npm
- node-libnpmteam
- node-npmcli-promise-spawn
- node-libnpmdiff
- node-npmcli-run-script
- node-npmcli-metavuln-calculator
- node-npmcli-smoke-tests
- node-libnpmpublish
- node-qrcode-terminal
- node-npmcli-config
- node-npmcli-git
- node-libnpmaccess
- node-npm-packlist
- node-npmcli-disparity-colors
- node-libnpmexec
- node-npmcli-installed-package-contents
- node-libnpmpack
- node-npmcli-map-workspaces
- node-npmcli-query
- node-npmcli-arborist
- node-npmcli-package-json
- node-libnpmhook
- node-npmcli-name-from-folder
- node-libnpmversion
- node-libnpmfund
- node-libnpmsearch
apt-get install npm
Manual
NPM-QUERY
NAMESynopsis
Description
Piping npm query to other commands
Extended Use Cases & Queries
Example Response Output
Configuration
See Also
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 |