ID Selectors
ID selectors are a shorthand for selecting packages by name. They work
like
CSS ID selectors
but match the name field in package.json.
Syntax
#package-nameThis is equivalent to [name=package-name].
:::caution ID selectors only work for unscoped packages. For
scoped packages (e.g. @vltpkg/cli), use
attribute selectors instead:
[name=@vltpkg/cli]. :::
Examples
Select a package by name:
$ vlt query '#react'This is the same as:
$ vlt query '[name=react]'Combining with combinators
Find all dependencies of react:
$ vlt query '#react > *'Find direct deps that have react as a sibling:
$ vlt query '#react ~ *'Combining with pseudo-classes
Check if a specific package is outdated:
$ vlt query '#typescript:outdated'When to use attribute selectors instead
Use [name=value] instead of #value when:
- The package is scoped:
[name=@vltpkg/cli] - You need partial matching:
[name^=react](starts with “react”) - You need case-insensitive matching:
[name=React i]
See also
- Attribute Selectors — full attribute matching syntax