选择命令行版本:
🌐 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.
请参阅 config 以获得有关所涉及机制的更详细解释,以及可用配置选项的完整列表。
🌐 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:
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, 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.
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.
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.
npm config delete key [key ...]
从所有配置文件中删除指定的键。
🌐 Deletes the specified keys from all configuration files.
npm config edit
在编辑器中打开配置文件。使用 --global 标志编辑全局配置。
🌐 Opens the config file in an editor. Use the --global flag to edit the global config.
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是否输出 JSON 数据,而不是正常输出。
🌐 Whether or not to output JSON data, rather than the normal output.
npm pkg set 中,它可以在将值保存到你的 package.json 之前使用 JSON.parse() 解析设置的值。并非所有 npm 命令都支持。
🌐 Not supported by all npm commands.
global以“全局”模式运行,因此软件包会安装到 prefix 文件夹中,而不是当前工作目录。有关行为差异的更多信息,请参见 folders。
🌐 Operates in "global" mode, so that packages are installed into the prefix folder instead of the current working directory. See folders for more on the differences in behavior.
{prefix}/lib/node_modules 文件夹中,而不是当前工作目录。{prefix}/bin 关联{prefix}/share/maneditor运行 npm edit 和 npm config edit 的命令。
🌐 The command to run for npm edit and npm config edit.
location--global,否则为 "user",传入后该值也会设置为 "global"当传递给 npm config 时,这指的是使用哪个配置文件。
🌐 When passed to npm config this refers to which config file to use.
当设置为“全局”模式时,软件包会安装到 prefix 文件夹,而不是当前工作目录。有关行为差异的更多信息,请参见 文件夹。
🌐 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}/lib/node_modules 文件夹中,而不是当前工作目录。{prefix}/bin 关联{prefix}/share/manlong在 ls、search 和 help-search 中显示扩展信息。
🌐 Show extended information in ls, search, and help-search.
🌐 See Also