选择命令行版本:
🌐 Synopsis
npm search <search term> [<search term> ...]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
json是否输出 JSON 数据,而不是正常输出。
🌐 Whether or not to output JSON data, rather than the normal output.
npm pkg set 中,它可以在将值保存到你的 package.json 之前使用 JSON.parse() 解析设置的值。并非所有 npm 命令都支持。
🌐 Not supported by all npm commands.
color如果为 false,则从不显示颜色。如果为 "always",则始终显示颜色。如果为 true,则仅为 tty 文件描述符打印颜色代码。
🌐 If false, never shows colors. If "always" then always shows colors. If true, then only prints color codes for tty file descriptors.
parseable从写入标准输出的命令中输出可解析的结果。对于 npm search,这将是制表符分隔的表格格式。
🌐 Output parseable results from commands that write to standard output. For npm search, this will be tab-separated table format.
description在 npm search 中显示描述
🌐 Show the description in npm search
searchlimit要限制搜索结果的项目数量。对旧版搜索完全不适用。
🌐 Number of items to limit search results to. Will not apply at all to legacy searches.
searchopts始终传递给搜索的空格分隔选项。
🌐 Space-separated options that are always passed to search.
searchexclude限制搜索结果的空格分隔选项。
🌐 Space-separated options that limit the results from search.
registrynpm 注册表的基本 URL。
🌐 The base URL of the npm registry.
prefer-online如果为 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如果为真,缓存数据的陈旧性检查将被跳过,但缺失的数据将从服务器请求。要强制完全离线模式,请使用 --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强制离线模式:安装过程中不会进行任何网络请求。若要允许 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