npm-search

搜索包

选择 CLI 版本:

概要

Synopsis

npm search [search terms ...]
aliases: find, s, se

注意:此命令对工作区无感知。

Note: This command is unaware of workspaces.

描述

Description

在注册表中搜索与搜索词匹配的包。npm search 通过包元数据对注册表中的所有文件执行线性、增量、按词法排序的搜索。如果你的终端支持颜色,它将进一步高亮结果中的匹配项。这可以通过配置项 color 禁用

Search the registry for packages matching the search terms. npm search performs a linear, incremental, lexically-ordered search through package metadata for all files in the registry. If your terminal has color support, it will further highlight the matches in the results. This can be disabled with the config item color

此外,使用与更多搜索词配对的 --searchopts--searchexclude 选项将包括和排除更多模式。--searchopts 和标准搜索词的主要区别在于前者不会在输出中高亮结果,你可以使用它们进行更细粒度的过滤。此外,你可以将这两者都添加到你的配置中以更改默认搜索过滤行为。

Additionally, using the --searchopts and --searchexclude options paired with more search terms will include and exclude further patterns. The main difference between --searchopts and the standard search terms is that the former does not highlight results in the output and you can use them more fine-grained filtering. Additionally, you can add both of these to your config to change default search filtering behavior.

搜索还允许在搜索结果中定位维护者,方法是在他们的 npm 用户名前加上 =

Search also allows targeting of maintainers in search results, by prefixing their npm username with =.

如果一个词以 / 开头,那么它会被解释为一个正则表达式并支持标准的 JavaScript RegExp 语法。在这种情况下,搜索将忽略尾随的 / 。 (请注意,在大多数 shell 中,你必须转义或引用许多正则表达式字符。)

If a term starts with /, then it's interpreted as a regular expression and supports standard JavaScript RegExp syntax. In this case search will ignore a trailing / . (Note you must escape or quote many regular expression characters in most shells.)

配置

Configuration

long

  • 默认值:false

    Default: false

  • 类型:布尔值

    Type: Boolean

lssearchhelp-search 中显示扩展信息。

Show extended information in ls, search, and help-search.

json

  • 默认值:false

    Default: false

  • 类型:布尔值

    Type: Boolean

是否输出 JSON 数据,而不是正常输出。

Whether or not to output JSON data, rather than the normal output.

  • npm pkg set 中,它可以使用 JSON.parse() 解析集合值,然后再将它们保存到你的 package.json

    In npm pkg set it enables parsing set values with JSON.parse() before saving them to your package.json.

并非所有 npm 命令都支持。

Not supported by all npm commands.

color

  • 默认值:true 除非 NO_COLOR 环境设置为 '0' 以外的值

    Default: true unless the NO_COLOR environ is set to something other than '0'

  • 类型:"always" 或布尔值

    Type: "always" or Boolean

如果为 false,则从不显示颜色。如果 "always" 则始终显示颜色。如果为真,则仅打印 tty 文件描述符的颜色代码。

If false, never shows colors. If "always" then always shows colors. If true, then only prints color codes for tty file descriptors.

parseable

  • 默认值:false

    Default: false

  • 类型:布尔值

    Type: Boolean

从写入标准输出的命令输出可解析的结果。对于 npm search,这将是制表符分隔的表格格式。

Output parseable results from commands that write to standard output. For npm search, this will be tab-separated table format.

description

  • 默认值:true

    Default: true

  • 类型:布尔值

    Type: Boolean

显示 npm search 中的描述

Show the description in npm search

searchopts

  • 默认值:""

    Default: ""

  • 类型:字符串

    Type: String

始终传递给搜索的空格分隔选项。

Space-separated options that are always passed to search.

searchexclude

  • 默认值:""

    Default: ""

  • 类型:字符串

    Type: String

限制搜索结果的空格分隔选项。

Space-separated options that limit the results from search.

registry

npm 注册表的基本 URL。

The base URL of the npm registry.

prefer-online

  • 默认值:false

    Default: false

  • 类型:布尔值

    Type: Boolean

如果为 true,将强制检查缓存数据的时效性,使 CLI 立即查找更新,即使是新的包数据也是如此。

If true, staleness checks for cached data will be forced, making the CLI look for updates immediately even for fresh package data.

prefer-offline

  • 默认值:false

    Default: false

  • 类型:布尔值

    Type: Boolean

如果为 true,将绕过缓存数据的过时检查,但将从服务器请求丢失的数据。要强制完全离线模式,请使用 --offline

If true, staleness checks for cached data will be bypassed, but missing data will be requested from the server. To force full offline mode, use --offline.

offline

  • 默认值:false

    Default: false

  • 类型:布尔值

    Type: Boolean

强制离线模式:安装期间不会完成任何网络请求。要允许 CLI 填充缺失的缓存数据,请参阅 --prefer-offline

Force offline mode: no network requests will be done during install. To allow the CLI to fill in missing cache data, see --prefer-offline.

也可以看看

See Also

npm 中文网 - 粤ICP备13048890号