@@ -16,35 +16,42 @@ aliases: s, se, find
1616
1717Search the registry for packages matching the search terms. ` npm search `
1818performs a linear, incremental, lexically-ordered search through package
19- metadata for all files in the registry. If color is enabled, it will further
20- highlight the matches in the results.
19+ metadata for all files in the registry. If your terminal has color
20+ support, it will further highlight the matches in the results. This can
21+ be disabled with the config item ` color `
2122
22- Additionally, using the ` --searchopts ` and ` --searchexclude ` options paired with
23- more search terms will respectively include and exclude further patterns. The
24- main difference between ` --searchopts ` and the standard search terms is that the
25- former does not highlight results in the output and can be used for more
26- fine-grained filtering. Additionally, both of these can be added to ` .npmrc ` for
27- default search filtering behavior.
23+ Additionally, using the ` --searchopts ` and ` --searchexclude ` options
24+ paired with more search terms will include and exclude further patterns.
25+ The main difference between ` --searchopts ` and the standard search terms
26+ is that the former does not highlight results in the output and you can
27+ use them more fine-grained filtering. Additionally, you can add both of
28+ these to your config to change default search filtering behavior.
2829
2930Search also allows targeting of maintainers in search results, by prefixing
3031their npm username with ` = ` .
3132
32- If a term starts with ` / ` , then it's interpreted as a regular expression and
33- supports standard JavaScript RegExp syntax. A trailing ` / ` will be ignored in
34- this case. (Note that many regular expression characters must be escaped or
35- quoted in most shells.)
36-
37- ### A Note on caching
33+ If a term starts with ` / ` , then it's interpreted as a regular expression
34+ and supports standard JavaScript RegExp syntax. In this case search will
35+ ignore a trailing ` / ` . (Note you must escape or quote many regular
36+ expression characters in most shells.)
3837
3938### Configuration
4039
40+ All of the following can be defined in a ` .npmrc ` file, or passed as
41+ parameters to the cli prefixed with ` -- ` (e.g. ` --json ` )
42+
4143#### description
4244
4345* Default: true
4446* Type: Boolean
4547
46- Used as ` --no-description ` , disables search matching in package descriptions and
47- suppresses display of that field in results.
48+ #### color
49+
50+ * Default: true
51+ * Type: Boolean
52+
53+ Used as ` --no-color ` , disables color highlighting of matches in the
54+ results.
4855
4956#### json
5057
@@ -66,9 +73,9 @@ Output search results as lines with tab-separated columns.
6673* Type: Boolean
6774
6875Display full package descriptions and other long text across multiple
69- lines. When disabled (default) search results are truncated to fit
70- neatly on a single line. Modules with extremely long names will
71- fall on multiple lines.
76+ lines. When disabled (which is the default) the output will
77+ truncate search results to fit neatly on a single line. Modules with
78+ extremely long names will fall on multiple lines.
7279
7380#### searchopts
7481
@@ -84,27 +91,43 @@ Space-separated options that are always passed to search.
8491
8592Space-separated options that limit the results from search.
8693
87- #### searchstaleness
88-
89- * Default: 900 (15 minutes)
90- * Type: Number
91-
92- The age of the cache, in seconds, before another registry request is made.
93-
9494#### registry
9595
9696 * Default: https://registry.npmjs.org/
9797 * Type: url
9898
99- Search the specified registry for modules. If you have configured npm to point
100- to a different default registry, such as your internal private module
101- repository, ` npm search ` will default to that registry when searching. Pass a
102- different registry url such as the default above in order to override this
103- setting.
99+ Search the specified registry for modules. If you have configured npm to
100+ point to a different default registry (such as your internal private
101+ module repository), ` npm search ` will also default to that registry when
102+ searching.
103+
104+ ### A note on caching
105+
106+ The npm cli caches search results with the same terms and options
107+ locally in its cache. You can use the following to change how and when
108+ the cli uses this cache. See [ ` npm cache ` ] ( /commands/npm-cache ) for more
109+ on how the cache works.
110+
111+ #### prefer-online
112+
113+ Forced staleness checks for cached searches, making the cli look for
114+ updates immediately even for fresh search results.
115+
116+ #### prefer-offline
117+
118+ Bypasses staleness checks for cached. Missing data will still be
119+ requested from the server. To force full offline mode, use ` offline ` .
120+
121+ #### offline
122+
123+ Forces full offline mode. Any searches not locally cached will result in
124+ an error.
104125
105126### See Also
106127
107128* [ npm registry] ( /using-npm/registry )
108129* [ npm config] ( /commands/npm-config )
109130* [ npmrc] ( /configuring-npm/npmrc )
110131* [ npm view] ( /commands/npm-view )
132+ * [ npm cache] ( /commands/npm-cache )
133+ * https://npm.im/npm-registry-fetch
0 commit comments