File size: 4,267 Bytes
c6b68af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---

title: npm-config
section: 1
description: Manage the npm configuration files
---


### Synopsis

```bash

npm config set <key>=<value> [<key>=<value> ...]

npm config get [<key> [<key> ...]]

npm config delete <key> [<key> ...]

npm config list [--json]

npm config edit

npm config fix



alias: c

```

Note: This command is unaware of workspaces.

### Description

npm gets its config settings from the command line, environment variables, `npmrc` files, and in some cases, the `package.json` file.

See [npmrc](/configuring-npm/npmrc) for more information about the npmrc files.

See [config](/using-npm/config) for a more thorough explanation of the mechanisms involved, and a full list of config options available.

The `npm config` command can be used to update and edit the contents of the user and global npmrc files.

### Sub-commands

Config supports the following sub-commands:

#### set

```bash

npm config set key=value [key=value...]

npm set key=value [key=value...]

```

Sets each of the config keys to the value provided.
Modifies the user configuration file unless [`location`](/commands/npm-config#location) is passed.

If value is omitted, the key will be removed from your config file entirely.

Note: for backwards compatibility, `npm config set key value` is supported as an alias for `npm config set key=value`.

#### get

```bash

npm config get [key ...]

npm get [key ...]

```

Echo the config value(s) to stdout.

If multiple keys are provided, then the values will be prefixed with the key names.

If no keys are provided, then this command behaves the same as `npm config list`.

#### list

```bash

npm config list

```

Show all the config settings.
Use `-l` to also show defaults.
Use `--json` to show the settings in json format.

#### delete

```bash

npm config delete key [key ...]

```

Deletes the specified keys from all configuration files.

#### edit

```bash

npm config edit

```

Opens the config file in an editor.
Use the `--global` flag to edit the global config.

#### fix

```bash

npm config fix

```

Attempts to repair invalid configuration items.
Usually this means attaching authentication config (i.e.
`_auth`, `_authToken`) to the configured `registry`.

### Configuration

#### `json`

* Default: false
* Type: Boolean

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

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

Not supported by all npm commands.



#### `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
[folders](/configuring-npm/folders) for more on the differences in behavior.

* packages are installed into the `{prefix}/lib/node_modules` folder, instead
  of the current working directory.
* bin files are linked to `{prefix}/bin`
* man pages are linked to `{prefix}/share/man`



#### `editor`

* Default: The EDITOR or VISUAL environment variables, or
  '%SYSTEMROOT%\notepad.exe' on Windows, or 'vi' on Unix systems
* Type: String

The command to run for `npm edit` and `npm config edit`.



#### `location`

* Default: "user" unless `--global` is passed, which will also set this value
  to "global"
* Type: "global", "user", or "project"

When passed to `npm config` this refers to which config file to use.

When set to "global" mode, packages are installed into the `prefix` folder
instead of the current working directory. See
[folders](/configuring-npm/folders) for more on the differences in behavior.

* packages are installed into the `{prefix}/lib/node_modules` folder, instead
  of the current working directory.
* bin files are linked to `{prefix}/bin`
* man pages are linked to `{prefix}/share/man`



#### `long`

* Default: false
* Type: Boolean

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



### See Also

* [npm folders](/configuring-npm/folders)
* [npm config](/commands/npm-config)
* [package.json](/configuring-npm/package-json)
* [npmrc](/configuring-npm/npmrc)
* [npm](/commands/npm)