Налаштування (pnpm-workspace.yaml)
pnpm отримує налаштування з командного рядка, змінних середовища та файлу pnpm-workspace.yaml.
З файлів .npmrc зчитуються лише налаштування автентифікації та реєстру. Усі інші налаштування (наприклад, hoistPattern, nodeLinker, shamefullyHoist тощо) мають бути налаштовані у pnpm-workspace.yaml або глобальному файлі ~/.config/pnpm/config.yaml.
Команду pnpm config можна використовувати для читання та редагування вмісту файлів проєкту та файлів глобальної конфігурації.
Відповідні конфігураційні файли:
- Конфігураційний файл для кожного проєкту:
/path/to/my/project/pnpm-workspace.yaml - Глобальний файл конфігурації
Налаштування, пов'язані з авторизацією, обробляються через .npmrc.
Значення у файлах конфігурації можуть містити змінні env із використанням синтаксису ${NAME}. Змінні env також можуть бути вказані зі стандартними значеннями. Використання ${NAME-fallback} поверне fallback, якщо NAME не задано. ${NAME:-fallback} поверне fallback, якщо NAME не задано або є порожнім рядком.
Since v11.5.3, env variables are not expanded in settings of pnpm-workspace.yaml that define registry URLs: registry and the URL values of registries and namedRegistries. Values containing a ${...} placeholder in these settings are ignored. In the registry declaration shape of registries (since v11.23.0), the URL is the key rather than the value, and the same rule applies to the keys. Because pnpm-workspace.yaml is committed to the repository, expanding env variables in registry URLs could be exploited by a malicious repository to leak secrets from the environment to an attacker-controlled registry. Configure dynamic registry URLs in a trusted location instead: the global configuration file or CLI options.
Since v11.22.0, a project's pnpm-workspace.yaml cannot choose where pnpm keeps its credentials, its own installation, or other machine-level state: bin, configDir, dir, globalBinDir, globalDir, npmrcAuthFile, pnpmHomeDir, stateDir, userconfig, and workspaceDir are ignored there, with a warning. Set them in the global configuration file or on the command line instead. cacheDir and storeDir are unaffected.
packages
Besides settings, pnpm-workspace.yaml defines the root of the workspace and
enables you to include / exclude directories from the workspace. If the
packages field is omitted, only the root package is included in the workspace.
Наприклад:
packages:
# вказує на пакунок у безпосередній теці кореня
- 'my-app'
# всі пакунки в безпосередніх вкладених теках packages/
- 'packages/*'
# всі пакунки у вкладених теках components/
- 'components/**'
# виключити пакунки, які знаходяться всередині тестових тек
- '!**/test/**'
Кореневий пакунок завжди включається, навіть якщо використовуються користувацькі шаблони розташування.
Каталоги також визначено у файлі pnpm-workspace.yaml. Докладніше див. у Каталоги.
packages:
- 'packages/*'
catalog:
chalk: ^4.1.2
catalogs:
react16:
react: ^16.7.0
react-dom: ^16.7.0
react17:
react: ^17.10.0
react-dom: ^17.10.0
packageConfigs
Додано у: v11.0.0
Дозволяє налаштовувати параметри для окремих пакунків робочого простору відповідно до вимог конкретного проєкту. Це замінює файли .npmrc, що належать до конкретних проєктів у робочому просторі.
packageConfigs можна вказати у вигляді мапи, в якій імена пакунків відповідають об’єктам конфігурації:
packages:
- "packages/project-1"
- "packages/project-2"
packageConfigs:
"project-1":
saveExact: true
"project-2":
savePrefix: "~"
Або у вигляді масиву правил, що відповідають шаблонам:
packages:
- "packages/project-1"
- "packages/project-2"
packageConfigs:
- match: ["project-1", "project-2"]
modulesDir: "node_modules"
saveExact: true
Налаштування
Every setting is listed below, grouped by topic. Follow a setting to read its documentation, or open the full reference of a group.
Розвʼязання залежностей
- overrides
- packageExtensions
- allowedDeprecatedVersions
- update
- supportedArchitectures
- ignoredOptionalDependencies
- minimumReleaseAge
- minimumReleaseAgeExclude
- minimumReleaseAgeExcludePrune
- minimumReleaseAgeIgnoreMissingTime
- minimumReleaseAgeStrict
- trustPolicy
- trustPolicyExclude
- trustPolicyIgnoreAfter
- trustLockfile
- blockExoticSubdeps
- registries
- namedRegistries
Параметри модулів
- modulesDir
- nodeLinker
- nodeExperimentalPackageMap
- nodePackageMapType
- symlink
- enableModulesDir
- virtualStoreDir
- virtualStoreDirMaxLength
- virtualStoreOnly
- packageImportMethod
- modulesCacheMaxAge
- dlxCacheMaxAge
- enableGlobalVirtualStore
Налаштування підйому залежностей
Налаштування сховища
Параметри Lockfile
- lockfile
- preferFrozenLockfile
- lockfileIncludeTarballUrl
- gitBranchLockfile
- mergeGitBranchLockfilesBranchPattern
- peersSuffixMaxLength
Налаштування мережі
Налаштування запиту
- gitShallowHosts
- networkConcurrency
- fetchRetries
- fetchRetryFactor
- fetchRetryMintimeout
- fetchRetryMaxtimeout
- fetchTimeout
- fetchWarnTimeoutMs
- fetchMinSpeedKiBps
Параметри прямих залежностей
- autoInstallPeers
- dedupePeerDependents
- dedupePeers
- strictPeerDependencies
- resolvePeersFromWorkspaceRoot
- peerDependencyRules
Параметри CLI
- [no-]color
- loglevel
- useBetaCli
- recursiveInstall
- engineStrict
- npmPath
- pmOnFail
- ignoreWorkspaceRootCheck
Параметри Node.js
Параметри збирання
- ignoreScripts
- childConcurrency
- sideEffectsCache
- sideEffectsCacheReadonly
- unsafePerm
- nodeOptions
- verifyDepsBeforeRun
- strictDepBuilds
- allowBuilds
- dangerouslyAllowAllBuilds
Versioning Settings
- versioning.fixed
- versioning.ignore
- versioning.maxBump
- versioning.lanes
- versioning.epics
- versioning.changelog.storage
Інші налаштування
- savePrefix
- tag
- globalDir
- globalBinDir
- npmrcAuthFile
- stateDir
- cacheDir
- useStderr
- updateNotifier
- preferSymlinkedExecutables
- ignoreCompatibilityDb
- resolutionMode
- registrySupportsTimeField
- extendNodePath
- deployAllFiles
- dedupeDirectDeps
- optimisticRepeatInstall
- requiredScripts
- enablePrePostScripts
- scriptShell
- shellEmulator
- catalogMode
- ci
- catalogPrune
Налаштування робочого простору
These settings are configured in pnpm-workspace.yaml as well, but are documented together with the workspace feature they belong to.
- linkWorkspacePackages
- injectWorkspacePackages
- dedupeInjectedDeps
- syncInjectedDepsAfterScripts
- preferWorkspacePackages
- sharedWorkspaceLockfile
- saveWorkspaceProtocol
- includeWorkspaceRoot
- ignoreWorkspaceCycles
- disallowWorkspaceCycles
- failIfNoMatch
Settings documented elsewhere
- patchedDependencies
- pnpmfile, globalPnpmfile та ignorePnpmfile
- Authorization settings, which are read from
.npmrc