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 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.npm从命令行、环境变量、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 your package.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 to bin文件链接到{prefix}/bin
  • man pages are linked to man页链接到{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 editnpm config edit运行的命令。

location

  • Default: "user" unless --global is passed, which will also set this value to "global"默认值:“user”,除非传递了--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 to bin文件链接到{prefix}/bin
  • man pages are linked to man页链接到{prefix}/share/man

long

  • Default: false默认值:false
  • Type: 类型:Boolean

Show extended information in ls, search, and help-search.lssearchhelp-search中显示扩展信息

See Also