1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
|
npm-config(1) -- Manage the npm configuration file
==================================================
## SYNOPSIS
npm config set <key> <value> [--global]
npm config get <key>
npm config delete <key>
npm config list
npm config edit
npm get <key>
npm set <key> <value> [--global]
## DESCRIPTION
npm gets its configuration values from 5 sources, in this priority:
* cli:
The command line flags. Putting `--foo bar` on the command line sets the
`foo` configuration parameter to `"bar"`. A `--` argument tells the cli
parser to stop reading flags. A `--flag` parameter that is at the *end* of
the command will be given the value of `true`.
* env:
Any environment variables that start with `npm_config_` will be interpreted
as a configuration parameter. For example, putting `npm_config_foo=bar` in
your environment will set the `foo` configuration parameter to `bar`. Any
environment configurations that are not given a value will be given the value
of `true`. Config values are case-insensitive, so `NPM_CONFIG_FOO=bar` will
work the same.
* $HOME/.npmrc (or the `userconfig` param, if set above):
This file is an ini-file formatted list of `key = value` parameters.
* $PREFIX/etc/npmrc (or the `globalconfig` param, if set above):
This file is an ini-file formatted list of `key = value` parameters
* default configs:
This is a set of configuration parameters that are internal to npm, and are
defaults if nothing else is specified.
## Sub-commands
Config supports the following sub-commands:
### set
npm config set key value
Sets the config key to the value.
If value is omitted, then it sets it to "true".
### get
npm config get key
Echo the config value to stdout.
### list
npm config list
Show all the config settings.
### delete
npm config delete key
Deletes the key from all configuration files.
### edit
npm config edit
Opens the config file in an editor. Use the `--global` flag to edit the
global config.
## Shorthands and Other CLI Niceties
The following shorthands are parsed on the command-line:
* `-v`: `--version`
* `-h`, `-?`, `--help`, `-H`: `--usage`
* `-s`, `--silent`: `--loglevel silent`
* `-d`: `--loglevel info`
* `-dd`, `--verbose`: `--loglevel verbose`
* `-ddd`: `--loglevel silly`
* `-g`: `--global`
* `-l`: `--long`
* `-p`, `--porcelain`: `--parseable`
* `-reg`: `--registry`
* `-v`: `--version`
* `-f`: `--force`
* `-l`: `--long`
* `-desc`: `--description`
* `ll` and `la` commands: `ls --long`
If the specified configuration param resolves unambiguously to a known
configuration parameter, then it is expanded to that configuration
parameter. For example:
npm ls --par
# same as:
npm ls --parseable
If multiple single-character shorthands are strung together, and the
resulting combination is unambiguously not some other configuration
param, then it is expanded to its various component pieces. For
example:
npm ls -gpld
# same as:
npm ls --global --parseable --long --loglevel info
## Per-Package Config Settings
When running scripts (see `npm help scripts`)
the package.json "config" keys are overwritten in the environment if
there is a config param of `<name>[@<version>]:<key>`. For example, if
the package.json has this:
{ "name" : "foo"
, "config" : { "port" : "8080" }
, "scripts" : { "start" : "node server.js" } }
and the server.js is this:
http.createServer(...).listen(process.env.npm_package_config_port)
then the user could change the behavior by doing:
npm config set foo:port 80
## Config Settings
### browser
* Default: OS X: `"open"`, others: `"google-chrome"`
* Type: String
The browser that is called by the `npm docs` command to open websites.
### cache
* Default: Windows: `~/npm-cache`, Posix: `~/.npm`
* Type: path
The location of npm's cache directory. See `npm help cache`
### color
* Default: true
* Type: Boolean or `"always"`
If false, never shows colors. If `"always"` then always shows colors.
If true, then only prints color codes for tty file descriptors.
### depth
* Default: Infinity
* Type: Number
The depth to go when recursing directories for `npm ls` and
`npm cache ls`.
### description
* Default: true
* Type: Boolean
Whether or not to show the description in `npm search`
### dev
* Default: false
* Type: Boolean
Whether or not to install `dev-dependencies` along with packages.
Note that `dev-dependencies` are also installed if the `npat` flag is
set.
### editor
* Default: `EDITOR` environment variable if set, or `"vi"`
* Type: path
The command to run for `npm edit` or `npm config edit`.
### force
* Default: false
* Type: Boolean
Makes various commands more forceful.
* lifecycle script failure does not block progress.
* publishing clobbers previously published versions.
* skips cache when requesting from the registry.
* prevents checks against clobbering non-npm files.
### global
* Default: false
* Type: Boolean
Operates in "global" mode, so that packages are installed into the
`prefix` folder instead of the current working directory. See
`npm help global` for more on the differences in behavior.
* packages are installed into the `prefix/node_modules` folder, instead of the
current working directory.
* bin files are linked to `prefix/bin`
* man pages are linked to `prefix/share/man`
### globalconfig
* Default: {prefix}/etc/npmrc
* Type: path
The config file to read for global config options.
### group
* Default: GID of the current process
* Type: String or Number
The group to use when running package scripts in global mode as the root
user.
### gzipbin
* Default: "gzip"
* Type: path
The gzip binary
### logfd
* Default: stderr file descriptor
* Type: Number or Stream
The location to write log output.
### loglevel
* Default: "warn"
* Type: String
* Values: "silent", "win", "error", "warn", "info", "verbose", "silly"
What level of logs to report. On failure, *all* logs are written to
`npm-debug.log` in the current working directory.
### long
* Default: false
* Type: Boolean
Whether or not to show extended information in `npm ls`
### node-version
* Default: process.version
* Type: semver
The node version to use when checking package's "engines" hash.
### npat
* Default: false
* Type: Boolean
Whether or not to run tests on installation and report results to the
`npaturl`.
### npaturl
* Default: Not yet implemented
* Type: url
The url to report npat test results.
### onload-script
* Default: false
* Type: path
A node module to `require()` when npm loads. Useful for programmatic
usage.
### outfd
* Default: standard output file descriptor
* Type: Number or Stream
Where to write "normal" output. This has no effect on log output.
### parseable
* Default: false
* Type: Boolean
Whether or not to output parseable results from commands that write to
standard output.
### prefix
* Default: node's process.installPrefix
* Type: path
The location to install global items. If set on the command line, then
it forces non-global commands to run in the specified folder.
### proxy
* Default: "HTTP_PROXY" or "http_proxy" environment variable, or null
* Type: url
A proxy to use for outgoing http requests.
### rebuild-bundle
* Default: true
* Type: Boolean
Set to some truish value to rebuild bundled dependencies after
installation.
### registry
* Default: https://registry.npmjs.org/
* Type: url
The base URL of the npm package registry.
### 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.
### shell
* Default: SHELL environment variable, or "bash"
* Type: path
The shell to run for the `npm explore` command.
### tag
* Default: latest
* Type: String
If you ask npm to install a package and don't tell it a specific version, then
it will install the specified tag.
Also the tag that is added to the package@version specified by the `npm
tag` command, if no explicit tag is given.
### tar
* Default: TAR environment variable, or "tar"
* Type: path
The tar executable
### tmp
* Default: TMPDIR environment variable, or "/tmp"
* Type: path
Where to store temporary files and folders. All temp files are deleted
on success, but left behind on failure for forensic purposes.
### unsafe-perm
* Default: false if running as root, true otherwise
* Type: Boolean
Set to true to suppress the UID/GID switching when running package
scripts. If set explicitly to false, then installing as a non-root user
will fail.
### usage
* Default: false
* Type: Boolean
Set to show short usage output (like the -H output)
instead of complete help when doing `npm help`.
### user
* Default: "nobody"
* Type: String or Number
The UID to set to when running package scripts as root.
### username
* Default: null
* Type: String
The username on the npm registry. Set with `npm adduser`
### userconfig
* Default: ~/.npmrc on Posix, or ~/npm-config on Windows
* Type: path
The location of user-level configuration settings.
### version
* Default: false
* Type: boolean
If true, output the npm version and exit successfully.
Only relevant when specified explicitly on the command line.
### viewer
* Default: "man"
* Type: path
The program to use to view help content.
|