pnpm config
Псевдоніми: c
Керування файлами конфігурації.
Налаштування pnpm розподілені між двома типами файлів конфігурації:
- Legacy and npm-compatible registry/authentication settings live in INI
files: the global
auth.inifile and local.npmrcfiles. - pnpm settings live in YAML files: the global
config.yamland the per-projectpnpm-workspace.yaml. The global file may also hold the structured_authandregistriesvalues that pnpm 12.1 and newer writes duringpnpm login.
The local workspace configuration file is located at the root of the project and is named pnpm-workspace.yaml. The global YAML configuration file (config.yaml) is located at:
- If $PNPM_CONFIG_HOME is non-empty, then $PNPM_CONFIG_HOME/config.yaml
- Otherwise, if the $XDG_CONFIG_HOME env variable is set, then $XDG_CONFIG_HOME/pnpm/config.yaml
- On Windows: ~/AppData/Local/pnpm/config/config.yaml
- On macOS: ~/Library/Preferences/pnpm/config.yaml
- On Linux: ~/.config/pnpm/config.yaml
The global auth.ini file uses the same directory. See Auth file locations.
You can also retrieve the path to your global config file by running:
pnpm config get globalconfig
Команди#
set <key> <value>#
Встановити значення для ключа конфігурації.
Без прапорця --json значення розбирається як звичайний рядок:
pnpm config set --location=project nodeVersion 22.0.0
З прапорцем --json він розбирається значення як JSON:
pnpm config set --location=project --json nodeVersion '"22.0.0"'
Прапорець --json також дозволяє pnpm config set створювати масиви та обʼєкти:
pnpm config set --location=project --json allowBuilds '{"react": true, "react-dom": true}'
pnpm config set --location=project --json catalog '{ "react": "19" }'
Команда set не приймає шлях до властивості.
pnpm config set refuses to write a setting to a project's pnpm-workspace.yaml that pnpm does not read from there, such as configDir, pnpmHomeDir, stateDir, and the other settings that name machine-level state. Since v12.1.0, this includes scope, which controls the machine-wide default for pnpm login. The command fails with ERR_PNPM_CONFIG_SET_NOT_A_PROJECT_SETTING, naming where the setting belongs when it belongs somewhere. pnpm config delete still clears such a key from a file that already carries it.
get <key>#
Print the config value at the provided property path. Strings, numbers, and booleans are printed as plain text, objects and arrays as JSON, and an unset key as undefined. With --json, every value is printed as JSON.
Ключ key може бути простим ключем:
pnpm config get nodeVersion
pnpm config get --json nodeVersion
pnpm config get --json packageExtensions
pnpm config get --json allowBuilds
pnpm config get --json catalog
Він також може бути шляхом до властивості:
pnpm config get 'packageExtensions["@babel/parser"].peerDependencies["@babel/types"]'
pnpm config get --json 'packageExtensions["@babel/parser"].peerDependencies["@babel/types"]'
pnpm config get 'allowBuilds.react'
pnpm config get --json 'allowBuilds.react'
pnpm config get catalog.react
pnpm config get --json catalog.react
Синтаксис шляху до властивості імітує шляхи до властивостей JavaScript.
delete <key>#
Видалити ключ конфігурації з файлу конфігурації.
list#
Показати всі параметри конфігурації. Вивід — це обʼєкт JSON.
pnpm config list masks tokens, usernames, passwords, TLS private keys, and credentials in proxy URLs. pnpm config get fails when asked for a protected auth setting.
Параметри#
--global, -g#
Встановити конфігурацію у файлі глобальної конфігурації.
With get and list, show the global configuration without the settings from the project's pnpm-workspace.yaml and .npmrc.
--location#
- Type: project, global
Стандартно для --location встановлено значення global.
When set to project, pnpm writes the setting to pnpm-workspace.yaml at the workspace root (or, for registry/auth settings, to the .npmrc in the workspace root).
When set to global, the behavior is the same as passing the --global option.
--json#
Зробити так, щоб get і list показували всі налаштування конфігурації у форматі JSON, а set аналізував значення як JSON.