Skip to content

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-name

This 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:

Terminal
$ vlt query '#react'

This is the same as:

Terminal
$ vlt query '[name=react]'

Combining with combinators

Find all dependencies of react:

Terminal
$ vlt query '#react > *'

Find direct deps that have react as a sibling:

Terminal
$ vlt query '#react ~ *'

Combining with pseudo-classes

Check if a specific package is outdated:

Terminal
$ 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