@@ -16,35 +16,42 @@ aliases: s, se, find
16
16
17
17
Search the registry for packages matching the search terms. ` npm search `
18
18
performs 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 `
21
22
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.
28
29
29
30
Search also allows targeting of maintainers in search results, by prefixing
30
31
their npm username with ` = ` .
31
32
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.)
38
37
39
38
### Configuration
40
39
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
+
41
43
#### description
42
44
43
45
* Default: true
44
46
* Type: Boolean
45
47
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.
48
55
49
56
#### json
50
57
@@ -66,9 +73,9 @@ Output search results as lines with tab-separated columns.
66
73
* Type: Boolean
67
74
68
75
Display 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.
72
79
73
80
#### searchopts
74
81
@@ -84,27 +91,43 @@ Space-separated options that are always passed to search.
84
91
85
92
Space-separated options that limit the results from search.
86
93
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
-
94
94
#### registry
95
95
96
96
* Default: https://registry.npmjs.org/
97
97
* Type: url
98
98
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.
104
125
105
126
### See Also
106
127
107
128
* [ npm registry] ( /using-npm/registry )
108
129
* [ npm config] ( /commands/npm-config )
109
130
* [ npmrc] ( /configuring-npm/npmrc )
110
131
* [ npm view] ( /commands/npm-view )
132
+ * [ npm cache] ( /commands/npm-cache )
133
+ * https://npm.im/npm-registry-fetch
0 commit comments