LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

npm-query

queries dependency graph with selectors

TLDR

Query dependencies
$ npm query "[name=lodash]"
copy
Find dev dependencies
$ npm query ":type(dev)"
copy
Find outdated
$ npm query ":outdated(major)"
copy
Find vulnerabilities
$ npm query ":vuln"
copy
Complex query
$ npm query "[name^=@babel]"
copy

SYNOPSIS

npm query selector

DESCRIPTION

npm query queries dependency graph with selectors. CSS-like syntax for packages.The command filters dependencies. Powerful package searching.

PARAMETERS

SELECTOR

CSS-like query selector. Supports pseudo-classes (`:root`, `:type(dev)`, `:outdated`, `:deprecated`, `:vuln`, `:attr`, `:semver`, `:path`), attribute selectors (`[name=foo]`, `[name^=@scope]`, `[keywords=cli]`) and combinators (` `, `>`, `,`).
--global
Query the globally-installed tree instead of the project.
--workspace NAME
Restrict the query to the given workspace(s).
--workspaces
Apply across every workspace.
--include-workspace-root
Include the workspace root package in the results.
--package-lock-only
Read from `package-lock.json` only, do not touch `node_modules`.
--expect-result-count N, --expect-results BOOL
Make npm exit non-zero if the result count does not match.
--help
Display help information.

CAVEATS

CSS selector syntax. Added in npm 8.16. Complex queries possible.

HISTORY

npm query was added to provide CSS-like querying of the dependency tree.

SEE ALSO

npm(1), npm-ls(1), npm-explain(1)

Copied to clipboard
Kai