Налаштування (pnpm-workspace.yaml)
pnpm отримує налаштування з командного рядка, змінних середовища та файлу pnpm-workspace.yaml.
Only auth, registry, TLS, proxy, and local-address settings are read from .npmrc files. All other settings are configured in pnpm-workspace.yaml or the global config.yaml. Some settings are limited to one of them: settings that define the structure of node_modules (like hoistPattern, publicHoistPattern, nodeLinker, or shamefullyHoist) can only be set in pnpm-workspace.yaml, while settings that name machine-level state (like stateDir or pnpmHomeDir) are not read from pnpm-workspace.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. Since v11.25.0, scope is ignored there too. 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
- optional
- ignoredOptionalDependencies
- forceIgnoresPlatform
- minimumReleaseAge
- minimumReleaseAgeExclude
- minimumReleaseAgeExcludePrune
- minimumReleaseAgeIgnoreMissingTime
- minimumReleaseAgeStrict
- trustPolicy
- trustPolicyExclude
- trustPolicyIgnoreAfter
- trustPolicyExcludePrune
- trustLockfile
- blockExoticSubdeps
- registries
- namedRegistries
- pnprServer
node_modules settings#
- modulesDir
- nodeLinker
- nodeExperimentalPackageMap
- nodePackageMapType
- symlink
- enableModulesDir
- confirmModulesPurge
- virtualStoreDir
- virtualStoreDirMaxLength
- virtualStoreOnly
- packageImportMethod
- modulesCacheMaxAge
- dlxCacheMaxAge
- virtualStoreType
- enableGlobalVirtualStore
Dependency hoisting settings#
Store settings#
Lockfile settings#
- lockfile
- frozenLockfile
- preferFrozenLockfile
- lockfileIncludeTarballUrl
- gitBranchLockfile
- mergeGitBranchLockfilesBranchPattern
- peersSuffixMaxLength
Network settings#
Request settings#
- gitShallowHosts
- networkConcurrency
- fetchRetries
- fetchRetryFactor
- fetchRetryMintimeout
- fetchRetryMaxtimeout
- fetchTimeout
- fetchWarnTimeoutMs
- fetchMinSpeedKiBps
- maxTarballUnpackedSize
Peer dependency settings#
- autoInstallPeers
- dedupePeerDependents
- dedupePeers
- strictPeerDependencies
- resolvePeersFromWorkspaceRoot
- peerDependencyRules
Параметри CLI#
Node.js settings#
Build settings#
- ignoreScripts
- childConcurrency
- sideEffectsCache
- sideEffectsCacheReadonly
- sideEffectsCache.remote
- unsafePerm
- nodeOptions
- verifyDepsBeforeRun
- strictDepBuilds
- allowBuilds
- dangerouslyAllowAllBuilds
Versioning settings#
- versioning.fixed
- versioning.ignore
- versioning.maxBump
- versioning.lanes
- versioning.epics
- versioning.changelog.storage
Other settings#
- savePrefix
- tag
- globalDir
- globalBinDir
- npmrcAuthFile
- stateDir
- cacheDir
- useStderr
- updateNotifier
- preferSymlinkedExecutables
- ignoreCompatibilityDb
- resolutionMode
- registrySupportsTimeField
- extendNodePath
- deployAllFiles
- dedupeDirectDeps
- optimisticRepeatInstall
- requiredScripts
- enablePrePostScripts
- scriptShell
- shellEmulator
- catalogMode
- ci
- catalogPrune
Workspace settings#
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
- workspaceConcurrency
- ignoreWorkspaceRootCheck
- failIfNoMatch
Settings documented elsewhere#
- patchedDependencies
- pnpmfile, globalPnpmfile та ignorePnpmfile
- audit.level, audit.ignore and audit.ignorePrune
- initVersion, initLicense and initAuthorName / initAuthorEmail / initAuthorUrl
- legacyDirFiltering
- Authorization settings, which are read from
.npmrc