vlt / docs

  • PricingBenchmarks (opens in new window)Community (opens in new window)Feedback
  • Overview
  • Attribute Selectors
  • Combinators
  • ID Selectors
  • Security Insights
  • Syntax
  • Examples
  • Combining with combinators
  • Combining with pseudo-classes
  • When to use attribute selectors instead
  • See also
  1. Client
  2. /
  3. Selectors
  4. /
  5. ID Selectors

ID Selectors

ID selectors are a shorthand for selecting packages by name. They work like CSS ID selectors but match the name a package is installed under.

Syntax

Text
#package-name

Matches the name a dependency is installed under, usually the same as [name=package-name]. With an alias like "ab": "npm:abbrev@2.0.0", #ab selects abbrev; a package installed under several names matches each.

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

  • Attribute Selectors — full attribute matching syntax

PreviousCombinatorsNextSecurity Insights

On this page

  • Syntax
  • Examples
  • Combining with combinators
  • Combining with pseudo-classes
  • When to use attribute selectors instead
  • See also
Edit this page

Deploy your package on vlt.io

Publish scoped and private packages, manage organizations and access, and give every developer and CI environment a consistent source for public and private JavaScript dependencies.

Publish now