mirror of
https://github.com/ivuorinen/cheatsheet-tldr.git
synced 2026-03-09 23:58:02 +00:00
Update cheatsheets
This commit is contained in:
38
npm-query
Normal file
38
npm-query
Normal file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
syntax: markdown
|
||||
tags: [tldr, common]
|
||||
source: https://github.com/tldr-pages/tldr.git
|
||||
---
|
||||
# npm query
|
||||
|
||||
> Print an array of dependency objects using CSS-like selectors.
|
||||
> More information: <https://docs.npmjs.com/cli/v8/commands/npm-query>.
|
||||
|
||||
- Print direct dependencies:
|
||||
|
||||
`npm query ':root > *'`
|
||||
|
||||
- Print all direct production/development dependencies:
|
||||
|
||||
`npm query ':root > .{{prod|dev}}'`
|
||||
|
||||
- Print dependencies with a specific name:
|
||||
|
||||
`npm query '#{{package}}'`
|
||||
|
||||
- Print dependencies with a specific name and within a semantic versioning range:
|
||||
|
||||
`npm query #{{package}}@{{semantic_version}}`
|
||||
|
||||
- Print dependencies which have no dependencies:
|
||||
|
||||
`npm query ':empty'`
|
||||
|
||||
- Find all dependencies with postinstall scripts and uninstall them:
|
||||
|
||||
`npm query ":attr(scripts, [postinstall])" | jq 'map(.name) | join("
|
||||
")' -r | xargs -I {} npm uninstall {}`
|
||||
|
||||
- Find all Git dependencies and print which application requires them:
|
||||
|
||||
`npm query ":type(git)" | jq 'map(.name)' | xargs -I {} npm why {}`
|
||||
Reference in New Issue
Block a user