qnm

repository·master·Indexed 24 days ago

https://github.com/ranyitz/qnm

A fast CLI utility for querying the node_modules directory, supporting both npm and yarn. qnm provides information on installed module versions, dependency trees, and release timing. Key features include an interactive fuzzy-search interface, a 'match' command for pattern matching, a 'doctor' command to identify heavy modules and duplications, and the ability to open package homepages or package.json files directly from the CLI.

Tokens
1.8K
Snippets
7
Records
21
Agent score
85%

What's inside qnm

  1. Use interactive fuzzy-search

    master

    Run qnm without any arguments to trigger an interactive, fzf-like fuzzy search interface. This allows you to browse and filter all modules in your node_modules directory.

    • Filter: Start typing to filter matches.
    • Navigation: Use arrow keys to move the cursor.
    • Selection: Press Enter to select an item.
    • Multi-select: Use TAB and Shift-TAB to mark multiple items.
    • Exit: Press CTRL-C or ESC to exit.
    bunx qnm
  2. Install or run qnm

    master

    While qnm can be installed globally, it is recommended to use npx or bunx to run it directly for better performance.

    To run without installing:

    bunx qnm [module]

    To install globally:

    npm i --global qnm
    bunx qnm [module]
  3. Get module information or use fuzzy search

    master

    The qnm CLI has a dual-purpose fallback mode when no specific command is provided:

    1. Fuzzy Search: If you provide no arguments (other than flags), qnm enters a fuzzy search mode.
    2. Module Lookup: If you provide a single argument that is not a command, qnm attempts to get information for that specific module.

    Example (Fuzzy Search):

    qnm

    Example (Module Lookup):

    qnm lodash
  4. Configure qnm options

    master

    Use the following flags to modify qnm behavior:

    • --no-remote: Do not fetch remote data from npm. This makes qnm run faster but provides a limited view.
    • -o, --open: Open the module's package.json file with the default editor.
    • -d, --debug: Show full error messages (useful for debugging).
    • --disable-colors: Disables most colors and styling (e.g., version colors).
  5. How to read qnm's output

    master

    The qnm CLI output uses a visual tree structure to represent module versions and their relationships. Here is how to interpret the symbols and columns:

    • Module Name: The path to the module (e.g., node_modules/camelcase).
    • Latest Version: Indicated by the or symbols and compared against the current version.
    • Version Comparison Symbols:
      • (Green): The version is equal to the latest version.
      • (Red): The version is behind the latest version.
    • Publish Time: Shown in grey (e.g., 11 months ago).
    • Dependency Context:
      • ├── and └─┬: Standard tree branching for nested dependencies.
      • (package-name): Indicates sub-dependencies that caused the version requirement (e.g., (boxen, yargs-parser)).
      • dependency of: Shows the relationship path to the module being inspected.
  6. Query a specific module

    master

    To see the installed versions and dependency tree of a specific module, provide the module name as an argument. qnm will show the version, how long ago it was released, and the dependency paths where the module is located.

    Example for lodash:

    bunx qnm lodash
    bunx qnm lodash
  7. Match modules using pattern matching

    master

    The match command works like grep, returning all modules that include the supplied string.

    Example to find all installed ESLint plugins:

    bunx qnm match eslint-plug
    bunx qnm match eslint-plug
  8. Analyze heavy modules with the doctor command

    master

    The doctor command (experimental) identifies the heaviest modules in your node_modules directory to help understand what is consuming disk space.

    To sort modules based on the amount of duplications they have:

    bunx qnm doctor --sort duplicates
    bunx qnm doctor --sort duplicates
  9. List all modules in node_modules

    master

    The list command (alias: ls) returns a list of all modules in the node_modules directory.

    Arguments:

    • --deps: List the versions of direct dependencies and devDependencies.
    • --remote: Fetch remote data (Note: this may be slow due to network requests).
    bunx qnm list
  10. Identify why a module is required

    master
    The requiredBy and whyInfo properties help trace dependency chains. requiredBy returns an array of package names that depend on this module. whyInfo provides a simplified representation of this dependency information using simplifyRequiredByInfo.