npm-config
Manage the npm configuration files
Synopsis
npm config set <key>=<value> [<key>=<value> ...]npm config get [<key> [<key> ...]]npm config delete <key> [<key> ...]npm config list [--json]npm config editnpm config fixalias: c
Note: This command is unaware of workspaces.注意:此命令不知道工作空间。
Description
npm gets its config settings from the command line, environment variables, npm从命令行、环境变量、npmrc
files, and in some cases, the package.json
file.npmrc
文件以及在某些情况下的package.json
文件中获取其配置设置。
See npmrc for more information about the npmrc files.有关npmrc文件的更多信息,请参阅npmrc。
See config for a more thorough explanation of the mechanisms involved, and a full list of config options available.有关所涉及的机制的更全面的解释,以及可用的配置选项的完整列表,请参阅config。
The npm config
command can be used to update and edit the contents of the user and global npmrc files.npm config
命令可用于更新和编辑用户和全局npmrc文件的内容。
Sub-commands
Config supports the following sub-commands:Config支持以下子命令:
set
npm config set key=value [key=value...]npm set key=value [key=value...]
Sets each of the config keys to the value provided.将每个配置键设置为所提供的值。
If value is omitted, then it sets it to an empty string.如果省略了值,则会将其设置为一个空字符串。
Note: for backwards compatibility, 注意:为了向后兼容,支持将npm config set key value
is supported as an alias for npm config set key=value
.npm config set key value
作为npm config set key=value
的别名。
get
npm config get [key ...]npm get [key ...]
Echo the config value(s) to stdout.将配置值回显到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
.npm config list
相同。
list
npm config list
Show all the config settings. 显示所有配置设置。Use 使用-l
to also show defaults. -l
也可以显示默认值。Use 使用--json
to show the settings in json format.--json
以json格式显示设置。
delete
npm config delete key [key ...]
Deletes the specified keys from all configuration files.从所有配置文件中删除指定的密钥。
edit
npm config edit
Opens the config file in an editor. 在编辑器中打开配置文件。Use the 使用--global
flag to edit the global config.--global
标志编辑全局配置。
fix
npm config fix
Attempts to repair invalid configuration items. 尝试修复无效的配置项。Usually this means attaching authentication config (i.e. 通常这意味着将身份验证配置(即_auth
, _authToken
) to the configured registry
._auth
、_authToken
)附加到配置的registry
中。
Configuration

json
Default: false默认值:false
Type:类型:Boolean
Whether or not to output JSON data, rather than the normal output.是否输出JSON数据,而不是正常输出。
In在npm pkg set
it enables parsing set values with JSON.parse() before saving them to yourpackage.json
.npm pkg set
中,它允许在将集合值保存到您的package.json
之前使用JSON.parse()
解析集合值。
Not supported by all npm commands.并非所有npm命令都支持。

global
Default: false默认值:false
Type:类型:Boolean
Operates in "global" mode, so that packages are installed into the 以“全局”模式操作,以便将包安装到prefix
folder instead of the current working directory. prefix
文件夹中,而不是当前工作目录中。See folders for more on the differences in behavior.有关行为差异的详细信息,请参阅文件夹。
packages are installed into the包被安装到{prefix}/lib/node_modules
folder, instead of the current working directory.{prefix}/lib/node_modules
文件夹中,而不是当前的工作目录中。bin files are linked tobin文件链接到{prefix}/bin
man pages are linked toman页链接到{prefix}/share/man

editor
Default: The EDITOR or VISUAL environment variables, or '%SYSTEMROOT%\notepad.exe' on Windows, or 'vi' on Unix systems默认值:EDITOR或VISUAL环境变量,或Windows上的“%SYSTEMROOT%\noted.exe”,或Unix系统上的“vi”- Type: String
The command to run for 为npm edit
and npm config edit
.npm edit
和npm config edit
运行的命令。

location
Default: "user" unless默认值:“user”,除非传递了--global
is passed, which will also set this value to "global"--global
,否则也会将此值设置为“global”Type: "global", "user", or "project"类型:“global”、“user”或“project”
When passed to 当传递给npm config
this refers to which config file to use.npm config
时,它指的是要使用的配置文件。
When set to "global" mode, packages are installed into the 当设置为“全局”模式时,程序包将安装到prefix
folder instead of the current working directory. See folders for more on the differences in behavior.prefix
文件夹中,而不是当前工作目录中。有关行为差异的详细信息,请参阅文件夹。
packages are installed into the包被安装到{prefix}/lib/node_modules
folder, instead of the current working directory.{prefix}/lib/node_modules
文件夹中,而不是当前的工作目录中。bin files are linked tobin文件链接到{prefix}/bin
man pages are linked toman页链接到{prefix}/share/man

long
Default: false默认值:false
Type:类型:Boolean
Show extended information in 在ls
, search
, and help-search
.ls
、search
和help-search
中显示扩展信息