npm-config
选择命令行版本:
See Details
目录
概要
¥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 从命令行、环境变量、npmrc
文件以及在某些情况下从 package.json
文件获取其配置设置。
¥npm gets its config settings from the command line, environment variables, npmrc
files, and in some cases, the package.json
file.
有关 npmrc 文件的更多信息,请参见 npmrc。
¥See npmrc for more information about the npmrc files.
有关所涉及机制的更详尽解释,以及可用配置选项的完整列表,请参阅 配置。
¥See config for a more thorough explanation of the mechanisms involved, and a full list of config options available.
npm config
命令可用于更新和编辑用户和全局 npmrc 文件的内容。
¥The npm config
command can be used to update and edit the contents of the user and global npmrc files.
子命令
¥Sub-commands
Config 支持以下子命令:
¥Config supports the following sub-commands:
set
npm config set key=value [key=value...]npm set key=value [key=value...]
将每个配置键设置为提供的值。修改用户配置文件,除非传递 location
。
¥Sets each of the config keys to the value provided. Modifies the user configuration file unless location
is passed.
如果省略值,则密钥将从你的配置文件中完全删除。
¥If value is omitted, the key will be removed from your config file entirely.
注意:为了向后兼容,支持 npm config set key value
作为 npm config set key=value
的别名。
¥Note: for backwards compatibility, npm config set key value
is supported as an alias for npm config set key=value
.
get
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.
如果未提供任何键,则此命令的行为与 npm config list
相同。
¥If no keys are provided, then this command behaves the same as npm config list
.
list
npm config list
显示所有配置设置。使用 -l
也可以显示默认值。使用 --json
以 json 格式显示设置。
¥Show all the config settings. Use -l
to also show defaults. Use --json
to show the settings in json format.
delete
npm config delete key [key ...]
从所有配置文件中删除指定的键。
¥Deletes the specified keys from all configuration files.
edit
npm config edit
在编辑器中打开配置文件。使用 --global
标志来编辑全局配置。
¥Opens the config file in an editor. Use the --global
flag to edit the global config.
fix
npm config fix
尝试修复无效的配置项。通常这意味着将身份验证配置(即 _auth
、_authToken
)附加到配置的 registry
。
¥Attempts to repair invalid configuration items. Usually this means attaching authentication config (i.e. _auth
, _authToken
) to the configured registry
.
配置
¥Configuration
json
-
默认值:false
¥Default: false
-
类型:布尔值
¥Type: Boolean
是否输出 JSON 数据,而不是正常输出。
¥Whether or not to output JSON data, rather than the normal output.
-
在
npm pkg set
中,它可以使用 JSON.parse() 解析集合值,然后再将它们保存到你的package.json
。