설정 (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 - Global configuration file
참고
인증 관련 설정은 .npmrc를 통해 처리됩니다.
설정 파일의 값은 ${NAME} 구문을 사용해 환경 변수를 포함할 수 있습니다. 환경 변수의 기본값을 지정할 수도 있습니다. ${NAME-fallback}을 사용하면 NAME이 설정되지 않은 경우 fallback을 반환합니다. ${NAME:-fallback}은 NAME이 설정되지 않았거나 빈 문자열인 경우 fallback을 반환합니다. Since v12.7.0, ${NAME?} expands to an empty string without a warning when NAME isn't set, as in npm.
경고
Env variables are not expanded in settings of pnpm-workspace.yaml that define registry URLs: registry and the URL values of registries and namedRegistries. A ${...} placeholder in these settings fails the command, because ignoring the URL would resolve packages from another registry. In the registry declaration shape of registries, the URL is the key rather than the value, and the same rule applies to the keys. pnpm-workspace.yaml은 저장소에 커밋되므로, 레지스트리 URL에서 환경 변수를 확장하면 악의적인 저장소가 이를 악용해 환경의 비밀 정보를 공격자가 제어하는 레지스트리로 유출할 수 있습니다. 대신 신뢰할 수 있는 위치, 즉 글로벌 설정 파일이나 CLI 옵션에서 동적 레지스트리 URL을 설정하세요.
Since v12.7.0, the same applies to userAgent: a userAgent in pnpm-workspace.yaml that contains a ${...} placeholder is ignored, because the user agent is sent to the configured registry with every request.
참고
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, macosBackup, npmrcAuthFile, pnpmHomeDir, scope, stateDir, userconfig, and workspaceDir are ignored there, with a warning. So are ci, globalShims, symlinkedLockfileTargetDirs, and tools. Of these, only globalShims may also be set in a pnpm-workspace.yaml in the pnpm home directory. Set them in the global configuration file or on the command line instead. cacheDir와 storeDir은 영향을 받지 않습니다.
packages#
pnpm-workspace.yaml은 설정 외에도 workspace의 루트를 정의하며, 워크스페이스에 디렉터리를 포함하거나 제외할 수 있게 해 줍니다. packages 필드를 생략하면 루트 패키지만 워크스페이스에 포함됩니다.
예시:
packages:
# specify a package in a direct subdir of the root
- 'my-app'
# all packages in direct subdirs of packages/
- 'packages/*'
# all packages in subdirs of components/
- 'components/**'
# exclude packages that are inside test directories
- '!**/test/**'
루트 패키지는 사용자 지정 위치 와일드카드가 사용되는 경우에도 항상 포함됩니다.
A pattern may be written with a ./ prefix, may contain . and .. segments,
and may repeat slashes: ./packages/* and packages//* select the same
projects, and !./packages/legacy excludes the same directory that
!packages/legacy does. A * never matches a name beginning with a dot, so
packages/* skips packages/.cache; name such a directory explicitly to
include it.
참고
pnpm reads the workspace from pnpm-workspace.yaml, not from the workspaces
field of the root package.json. Since v12.4.1, a root manifest that declares a
non-empty workspaces array in a project with no pnpm-workspace.yaml gets a
warning, because such an install silently links no project at all.
카탈로그도 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#
개별 워크스페이스 패키지에 대해 프로젝트별 설정을 지정할 수 있습니다. 이는 워크스페이스 프로젝트별 .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
Settings that shape resolution or the layout of node_modules (overrides,
hoist, modulesDir, saveExact, savePrefix, and their neighbours) take
effect per project only where each project has its own lockfile, that is with
sharedWorkspaceLockfile: false. A
workspace on the default shared lockfile has one resolution for every project,
so pnpm reports which entries it ignored instead of applying them silently.
설정#
모든 설정은 주제별로 그룹화되어 아래에 나열되어 있습니다. 각 설정을 따라가 문서를 읽거나, 그룹의 전체 레퍼런스를 여세요.
종속성 해석#
- overrides
- packageExtensions
- allowedDeprecatedVersions
- update
- supportedArchitectures
- optional
- ignoredOptionalDependencies
- forceIgnoresPlatform
- minimumReleaseAge
- minimumReleaseAgeExclude
- minimumReleaseAgeExcludePrune
- minimumReleaseAgeIgnoreMissingTime
- minimumReleaseAgeStrict
- trustPolicy
- trustPolicyExclude
- trustPolicyIgnoreAfter
- trustPolicyExcludePrune
- trustLockfile
- blockExoticSubdeps
- registries
- namedRegistries
- pnprServer
- autoDedupe
node_modules settings#
- modulesDir
- nodeLinker
- nodeLinker.excluded
- nodePackageMap.mode
- nodePackageMap.type
- nodeExperimentalPackageMap
- nodePackageMapType
- symlink
- enableModulesDir
- virtualStoreDir
- virtualStoreDirMaxLength
- virtualStoreOnly
- packageImportMethod
- modulesCacheMaxAge
- dlxCacheMaxAge
- virtualStoreType
- enableGlobalVirtualStore
- globalVirtualStoreDir
Dependency hoisting settings#
- hoist
- hoistPattern
- publicHoistPattern
- hoistWorkspacePackages
- shamefullyHoist
- hoistingLimits
- externalDependencies
Store settings#
Lockfile settings#
- lockfile
- lockfileDir
- frozenLockfile
- preferFrozenLockfile
- excludeLinksFromLockfile
- lockfileIncludeTarballUrl
- symlinkedLockfileTargetDirs
- lockfile.includeResolutionSettings
- lockfile.integrityTarget
- lockfile.format
- gitBranchLockfile
- mergeGitBranchLockfilesBranchPattern
- peersSuffixMaxLength
Network settings#
Request settings#
- gitShallowHosts
- networkConcurrency
- fetchRetries
- fetchRetryFactor
- fetchRetryMintimeout
- fetchRetryMaxtimeout
- fetchTimeout
- fetchWarnTimeoutMs
- fetchMinSpeedKiBps
- maxTarballUnpackedSize
Peer dependency settings#
- autoInstallPeers
- autoInstallPeersFromHighestMatch
- dedupePeerDependents
- projectScopedOptionalPeers
- dedupePeers
- addMissingPeerTypes
- strictPeerDependencies
- resolvePeersFromWorkspaceRoot
- peerDependencyRules
CLI 설정#
Node.js settings#
Build settings#
- ignoreScripts
- childConcurrency
- sideEffectsCache
- sideEffectsCacheReadonly
- sideEffectsCache.remote
- sideEffectsCache.exclude
- remoteCache
- unsafePerm
- nodeOptions
- verifyDepsBeforeRun
- strictDepBuilds
- allowBuilds
- permissions
- skills.dirs
- dangerouslyAllowAllBuilds
Versioning settings#
- versioning.fixed
- versioning.ignore
- versioning.maxBump
- versioning.lanes
- versioning.epics
- versioning.changelog.storage
Other settings#
- savePrefix
- saveExact
- saveTypes
- tag
- globalDir
- globalBinDir
- globalShims
- npmrcAuthFile
- stateDir
- cacheDir
- useStderr
- updateNotifier
- preferSymlinkedExecutables
- ignoreCompatibilityDb
- resolutionMode
- registrySupportsTimeField
- extendNodePath
- deployAllFiles
- embedReadme
- dedupeDirectDeps
- optimisticRepeatInstall
- requiredScripts
- enablePrePostScripts
- scriptShell
- shellEmulator
- catalogMode
- ci
- catalogPrune
- macosBackup.excludeModulesDir
- macosBackup.excludeStoreDir
Workspace settings#
이 설정들도 pnpm-workspace.yaml에서 구성하지만, 해당 설정이 속한 워크스페이스 기능과 함께 문서화되어 있습니다.
- linkWorkspacePackages
- injectWorkspacePackages
- dedupeInjectedDeps
- syncInjectedDepsAfterScripts
- preferWorkspacePackages
- sharedWorkspaceLockfile
- saveWorkspaceProtocol
- includeWorkspaceRoot
- ignoreWorkspaceCycles
- disallowWorkspaceCycles
- workspaceConcurrency
- ignoreWorkspaceRootCheck
- failIfNoMatch
다른 곳에 문서화된 설정#
- publishBranch and publishWaitTimeout
- patchedDependencies
- pnpmfile, globalPnpmfile 및 ignorePnpmfile
- audit.level, audit.ignore and audit.ignorePrune
- initPackageManager, initType, initVersion, initLicense and initAuthorName / initAuthorEmail / initAuthorUrl
- legacyDirFiltering
- concurrencyGroups
- tasks, pipelines and pipelineBase
- cargo.enabled and Cargo registries
- python.enabled, python.executable, Python indexes, python.extras and python.groups
- python.versions, python.overrides and python.constraints
.npmrc에서 읽는 인증 설정