본문으로 건너뛰기
버전: 8.x

.npmrc

pnpm은 커맨드라인, 환경변수, 그리고 .npmrc 파일을 통해 config를 구성할 수 있습니다.

pnpm config 커맨드를 사용하여 사용자 및 전역.npmrc 파일을 수정할 수 있습니다.

4개의 관련된 파일은 다음과 같습니다.

  • 프로젝트별 구성 파일 (/path/to/my/project/.npmrc)
  • 작업 공간별 구성 파일 (pnpm-workspace.yaml 파일이 포함된 디렉토리)
  • 사용자별 구성 파일 (~/.npmrc)
  • 전역 구성 파일 (/etc/npmrc)

모든 .npmrc 파일은 key = value 의 목록을 갖는 INI-formatted 형식의 파일입니다

Values in the .npmrc files may contain env variables using the ${NAME} syntax. The env variables may also be specified with default values. Using ${NAME-fallback} will return fallback if NAME isn't set. ${NAME:-fallback} will return fallback if NAME isn't set, or is an empty string.

의존성 호이스팅 설정

hoist

  • 기본값: true
  • 유형: boolean

true로 설정하면 모든 의존성은 node_modules/.pnpm/node_modules로 호이스팅 됩니다. 이는 목록에 없는 의존성이 node_modules 내부의 모든 패키지에 접근할 수 있도록 합니다.

hoist-workspace-packages

Added in: v8.14.0

  • 기본값: false
  • 유형: boolean

When true, packages from the workspaces are symlinked to either <workspace_root>/node_modules/.pnpm/node_modules or to <workspace_root>/node_modules depending on other hoisting settings (hoist-pattern and public-hoist-pattern).

hoist-pattern

  • 기본값: ['*']
  • 유형: String

어떤 패키지를 node_modules/.pnpm/node_modules로 호이스팅 해야 하는지 pnpm에 알립니다. 기본적으로 모든 패키지는 호이스팅됩니다, 하지만 유령 의존성을 갖는 잘못된 패키지를 알고 있다면 이 옵션을 이용해 유령 의존성을 호이스팅할 수 있습니다. (권장)

예를 들어:

hoist-pattern[]=*eslint*
hoist-pattern[]=*babel*

You may also exclude patterns from hoisting using !.

예를 들어:

hoist-pattern[]=*types*
hoist-pattern[]=!@types/react

public-hoist-pattern

  • 기본값: ['*eslint*', '*prettier*']
  • 유형: String

hoist-pattern은 가상 저장소 내부의 숨겨진 모듈 디렉토리에 대한 의존성을 호이스트하는 것과 달리, public-hoist-pattern 은 패턴과 일치하는 의존성을 루트 모듈 디렉토리에 호이스트합니다. 루트 모듈 디렉토리에 대한 호이스팅은 애플리케이션 코드가 해결 전략을 부적절하게 수정하더라도 유령 의존성에 액세스할 수 있음을 의미합니다.

이 설정은 의존성을 제대로 해결하지 못하는 일부 결함이 있는 플러그형 도구를 처리할 때 유용합니다.

예를 들어:

public-hoist-pattern[]=*plugin*

참고: shamefully-hoisttrue 로 설정하는 것은 public-hoist-pattern*로 설정하는 것과 같습니다.

You may also exclude patterns from hoisting using !.

예를 들어:

public-hoist-pattern[]=*types*
public-hoist-pattern[]=!@types/react

shamefully-hoist

  • 기본값: false
  • 유형: Boolean

기본적으로 pnpm은 반엄격한 node_modules을 생성합니다. 즉, 의존성은 선언되지 않은 의존성에 대해 액세스 권한을 갖지만 node_modules 외부의 모듈은 액세스할 수 없습니다. 이 레이아웃을 사용하면 생태계의 대부분의 패키지가 문제 없이 작동합니다. 그러나 일부 도구가 호이스트된 의존성이 node_modules의 루트에 있을 때만 작동하는 경우, 이를 true 로 설정하여 호이스트할 수 있습니다.

Node-Modules 설정

store-dir

  • 기본값:
    • If the $PNPM_HOME env variable is set, then $PNPM_HOME/store
    • $XDG_DATA_HOME env 변수가 설정되면 $XDG_DATA_HOME/pnpm/store
    • Windows: ~/AppData/Local/pnpm/store
    • macOS: ~/Library/pnpm/store
    • Linux: ~/.local/share/pnpm/store
  • 유형: path

모든 패키지가 저장되는 디스크 위치입니다.

저장소는 항상 설치가 발생하는 동일한 디스크에 있어야 합니다. 따라서 디스크당 하나의 저장소가 있도록 합니다. 현재 디스크에 홈 디렉토리가 있으면, 그 안에 저장소가 생성됩니다. 디스크에 홈이 없으면 파일 시스템의 루트에서 저장소가 생성됩니다. 예를 들어, /mnt에 마운트된 파일 시스템에서 설치가 진행 중인 경우, 저장소는 /mnt/.pnpm-store에 생성됩니다. Windows 시스템도 마찬가지입니다.

다른 디스크에서 저장소를 설정할 수 있지만, 이 경우 pnpm은 하드 링크 대신 저장소에서 패키지를 복사합니다. 하드 링크는 동일한 파일 시스템에서만 가능하기 때문입니다.

modules-dir

  • 기본값: node_modules
  • 유형: path

의존성이 설치될 디렉토리 (node_modules 대신).

node-linker

  • 기본값: isolated
  • 유형: isolated, hoisted, pnp

노드 패키지 설치에 사용해야 하는 링커를 정의합니다.

  • isolated - 의존성은 node_modules/.pnpm의 가상 저장소에서 심볼릭 링크됩니다.
  • hoisted - 심볼릭 링크가 없는 평탄한 node_modules 이 생성됩니다. npm 또는 Yarn Classic에 의해 생성된 node_modules 와 동일합니다. One of Yarn's libraries is used for hoisting, when this setting is used. 이 설정을 사용해야 하는 정당한 이유:
    1. 여러분의 도구가 심볼릭 링크와 잘 작동하지 않습니다. React Native 프로젝트는 호이스트된 node_modules을 사용하는 경우에만 작동합니다.
    2. 여러분의 프로젝트가 서버리스 호스팅 제공업체에 배포됩니다. 일부 서버리스 공급자 (예: AWS Lambda)는 심볼릭 링크를 지원하지 않습니다. 이 문제에 대한 대안 솔루션은 배포 전에 애플리케이션을 번들로 묶는 것입니다.
    3. "bundledDependencies"으로 패키지를 게시하려는 경우.
    4. --preserve-symlinks 플래그로 Node.js를 실행하는 경우.
  • pnp - node_modules 미사용. Plug'n'Play는 Yarn Berry에 의해 사용되는 Node.js를 위한 혁신적인 전략입니다. 링커로 pnp 를 사용할 때 symlink 설정을 false 으로 설정하는 것이 좋습니다.
  • 기본값: true
  • 유형: Boolean

symlinkfalse으로 설정되면 pnpm은 symlink가 없는 가상 저장소 디렉터리를 만듭니다. node-linker=pnp과 함께 사용하면 유용한 설정입니다.

enable-modules-dir

  • 기본값: true
  • 유형: Boolean

false이면 pnpm은 모듈 디렉토리 (node_modules)에 파일을 쓰지 않습니다. 이것은 모듈 디렉토리가 사용자 공간 (FUSE) 의 파일 시스템으로 마운트될 때 유용합니다. FUSE: @pnpm/mount-modules를 사용하여 모듈 디렉토리를 마운트할 수 있는 실험적 CLI가 있습니다.

virtual-store-dir

  • 기본값: node_modules/.pnpm
  • 유형: path

저장소에 대한 링크가 있는 디렉토리입니다. 프로젝트의 모든 직접 및 간접 의존성이 이 디렉토리에 연결됩니다.

이것은 Windows에서 긴 경로 문제를 해결할 수 있는 유용한 설정입니다. 매우 긴 경로에 대한 의존성이 있다면 여러분의 드라이브의 루트에서 가상 저장소를 선택할 수 있습니다 (예: C:\my-project-store).

또는 가상 저장소를 .pnpm 로 설정하고 .gitignore에 추가할 수 있습니다. 이렇게 하면 의존성 경로가 한 디렉토리 더 높기 때문에 스택 트레이스를 더 깔끔하게 만들 수 있습니다.

참고: 가상 저장소는 여러 프로젝트 간에 공유할 수 없습니다. 모든 프로젝트에는 자체 가상 저장소가 있어야 합니다(루트가 공유되는 워크스페이스 제외).

package-import-method

  • 기본값: auto
  • 유형: auto, hardlink, copy, clone, clone-or-copy

Controls the way packages are imported from the store (if you want to disable symlinks inside node_modules, then you need to change the node-linker setting, not this one).

  • auto - 저장소에서 패키지 복제를 시도합니다. 복제가 지원되지 않으면 저장소에서 패키지를 하드링크합니다. 복제도, 연결도 불가능하면 복사로 대체합니다.
  • hardlink - 저장소에서 패키지를 하드링크합니다.
  • clone-or-copy - 저장소에서 패키지 복제를 시도합니다. 복제가 지원되지 않으면 복사로 대체합니다.
  • copy - 저장소에서 패키지를 복사합니다.
  • clone - 저장소에서 패키지를 복제합니다 (copy-on-write 또는 레퍼런스 링크라고도 함).

node_modules에 패키지를 작성할 때 복제가 가장 좋은 방법입니다. 가장 빠르고 안전한 방법입니다. 복제를 사용하면 node_modules에서 파일을 편집할 수 있으며, 이는 중앙 content-addressable 저장소에서 수정되지 않습니다.

불행히도 모든 파일 시스템이 복제를 지원하는 것은 아닙니다. 최고의 pnpm 경험을 위해 CoW(Copy-On-Write) 파일 시스템(예: Linux에서 Ext4 대신 Btrfs)을 사용하는 것이 좋습니다.

modules-cache-max-age

  • 기본값: 10080 (7일(분))
  • 유형: number

모듈 디렉토리에서 고아 패키지를 제거해야 하는 시간(분)입니다. pnpm은 모듈 디렉토리에 패키지 캐시를 유지합니다. 이렇게 하면 브랜치를 전환하거나 의존성을 다운그레이드할 때 설치 속도가 향상됩니다.

Lockfile 설정

lockfile

  • 기본값: true
  • 유형: Boolean

false로 설정하면 pnpm은 pnpm-lock.yaml 파일을 읽거나 생성하지 않습니다.

prefer-frozen-lockfile

  • 기본값: true
  • 유형: Boolean

true 로 설정되고 사용 가능한 pnpm-lock.yamlpackage.json 의존성 지시문을 충족하면, 헤드리스 설치가 수행됩니다. 헤드리스 설치는 lockfile을 수정할 필요가 없기 때문에 모든 의존성 해결을 건너뜁니다.

lockfile-include-tarball-url

  • 기본값: false
  • 유형: Boolean

패키지의 tarball에 대한 전체 URL을 pnpm-lock.yaml의 모든 항목에 추가합니다.

git-branch-lockfile

  • 기본값: false
  • 유형: Boolean

When set to true, the generated lockfile name after installation will be named based on the current branch name to completely avoid merge conflicts. For example, if the current branch name is feature-foo, the corresponding lockfile name will be pnpm-lock.feature-foo.yaml instead of pnpm-lock.yaml. It is typically used in conjunction with the command line argument --merge-git-branch-lockfiles or by setting merge-git-branch-lockfiles-branch-pattern in the .npmrc file.

merge-git-branch-lockfiles-branch-pattern

  • Default: null
  • Type: Array or null

This configuration matches the current branch name to determine whether to merge all git branch lockfile files. By default, you need to manually pass the --merge-git-branch-lockfiles command line parameter. This configuration allows this process to be automatically completed.

예를 들어:

merge-git-branch-lockfiles-branch-pattern[]=main
merge-git-branch-lockfiles-branch-pattern[]=release*

You may also exclude patterns using !.

레지스트리 & 인증 설정

registry

The base URL of the npm package registry (trailing slash included).

<범위>: registry

The npm registry that should be used for packages of the specified scope. For example, setting @babel:registry=https://example.com/packages/npm/ will enforce that when you use pnpm add @babel/core, or any @babel scoped package, the package will be fetched from https://example.com/packages/npm instead of the default registry.

<URL>:_authToken

Define the authentication bearer token to use when accessing the specified registry. For example:

//registry.npmjs.org/:_authToken=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 

You may also use an environment variable. For example:

//registry.npmjs.org/:_authToken=${NPM_TOKEN}

Or you may just use an environment variable directly, without changing .npmrc at all:

npm_config_//registry.npmjs.org/:_authToken=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 

<URL>:tokenHelper

A token helper is an executable which outputs an auth token. This can be used in situations where the authToken is not a constant value but is something that refreshes regularly, where a script or other tool can use an existing refresh token to obtain a new access token.

The configuration for the path to the helper must be an absolute path, with no arguments. In order to be secure, it is only permitted to set this value in the user .npmrc. Otherwise a project could place a value in a project's local .npmrc and run arbitrary executables.

Setting a token helper for the default registry:

tokenHelper=/home/ivan/token-generator

Setting a token helper for the specified registry:

//registry.corp.com:tokenHelper=/home/ivan/token-generator

Request Settings

ca

  • Default: The npm CA certificate
  • Type: String, Array or null

The Certificate Authority signing certificate that is trusted for SSL connections to the registry. Values should be in PEM format (AKA "Base-64 encoded X.509 (.CER)"). For example:

ca="-----BEGIN CERTIFICATE-----\nXXXX\nXXXX\n-----END CERTIFICATE-----"

Set to null to only allow known registrars, or to a specific CA cert to trust only that specific signing authority.

Multiple CAs can be trusted by specifying an array of certificates:

ca[]="..."
ca[]="..."

See also the strict-ssl config.

cafile

  • Default: null
  • 유형: path

A path to a file containing one or multiple Certificate Authority signing certificates. Similar to the ca setting, but allows for multiple CAs, as well as for the CA information to be stored in a file instead of being specified via CLI.

cert

  • Default: null
  • Type: String

A client certificate to pass when accessing the registry. Values should be in PEM format (AKA "Base-64 encoded X.509 (.CER)"). For example:

cert="-----BEGIN CERTIFICATE-----\nXXXX\nXXXX\n-----END CERTIFICATE-----"

It is not the path to a certificate file (and there is no certfile option).

key

  • Default: null
  • Type: String

A client key to pass when accessing the registry. Values should be in PEM format (AKA "Base-64 encoded X.509 (.CER)"). For example:

key="-----BEGIN PRIVATE KEY-----\nXXXX\nXXXX\n-----END PRIVATE KEY-----"

It is not the path to a key file (and there is no keyfile option).

This setting contains sensitive information. Don't write it to a local .npmrc file committed to the repository.

git-shallow-hosts

  • Default: ['github.com', 'gist.github.com', 'gitlab.com', 'bitbucket.com', 'bitbucket.org']
  • 유형: String

When fetching dependencies that are Git repositories, if the host is listed in this setting, pnpm will use shallow cloning to fetch only the needed commit, not all the history.

https-proxy

  • Default: null
  • 유형: url

A proxy to use for outgoing HTTPS requests. If the HTTPS_PROXY, https_proxy, HTTP_PROXY or http_proxy environment variables are set, their values will be used instead.

If your proxy URL contains a username and password, make sure to URL-encode them. 예를 들어:

https-proxy=https://use%21r:pas%2As@my.proxy:1234/foo

Do not encode the colon (:) between the username and password.

http-proxy

proxy

  • Default: null
  • 유형: url

A proxy to use for outgoing http requests. If the HTTP_PROXY or http_proxy environment variables are set, proxy settings will be honored by the underlying request library.

local-address

  • Default: undefined
  • Type: IP Address

The IP address of the local interface to use when making connections to the npm registry.

maxsockets

  • Default: network-concurrency x 3
  • 유형: Number

The maximum number of connections to use per origin (protocol/host/port combination).

noproxy

  • Default: null
  • Type: String

A comma-separated string of domain extensions that a proxy should not be used for.

strict-ssl

  • 기본값: true
  • 유형: Boolean

Whether or not to do SSL key validation when making requests to the registry via HTTPS.

See also the ca option.

network-concurrency

  • Default: 16
  • 유형: Number

Controls the maximum number of HTTP(S) requests to process simultaneously.

fetch-retries

  • Default: 2
  • 유형: Number

How many times to retry if pnpm fails to fetch from the registry.

fetch-retry-factor

  • Default: 10
  • 유형: Number

The exponential factor for retry backoff.

fetch-retry-mintimeout

  • Default: 10000 (10 seconds)
  • 유형: Number

The minimum (base) timeout for retrying requests.

fetch-retry-maxtimeout

  • Default: 60000 (1 minute)
  • 유형: Number

The maximum fallback timeout to ensure the retry factor does not make requests too long.

fetch-timeout

  • Default: 60000 (1 minute)
  • 유형: Number

The maximum amount of time to wait for HTTP requests to complete.

Peer Dependency Settings

auto-install-peers

  • 기본값: true
  • 유형: Boolean

When true, any missing non-optional peer dependencies are automatically installed.

Version Conflicts

If there are conflicting version requirements for a peer dependency from different packages, pnpm will not install any version of the conflicting peer dependency automatically. Instead, a warning is printed. For example, if one dependency requires react@^16.0.0 and another requires react@^17.0.0, these requirements conflict, and no automatic installation will occur.

Conflict Resolution

In case of a version conflict, you'll need to evaluate which version of the peer dependency to install yourself, or update the dependencies to align their peer dependency requirements.

dedupe-peer-dependents

  • 기본값: true
  • 유형: Boolean

When this setting is set to true, packages with peer dependencies will be deduplicated after peers resolution.

For instance, let's say we have a workspace with two projects and both of them have webpack in their dependencies. webpack has esbuild in its optional peer dependencies, and one of the projects has esbuild in its dependencies. In this case, pnpm will link two instances of webpack to the node_modules/.pnpm directory: one with esbuild and another one without it:

node_modules
.pnpm
webpack@1.0.0_esbuild@1.0.0
webpack@1.0.0
project1
node_modules
webpack -> ../../node_modules/.pnpm/webpack@1.0.0/node_modules/webpack
project2
node_modules
webpack -> ../../node_modules/.pnpm/webpack@1.0.0_esbuild@1.0.0/node_modules/webpack
esbuild

This makes sense because webpack is used in two projects, and one of the projects doesn't have esbuild, so the two projects cannot share the same instance of webpack. However, this is not what most developers expect, especially since in a hoisted node_modules, there would only be one instance of webpack. Therefore, you may now use the dedupe-peer-dependents setting to deduplicate webpack when it has no conflicting peer dependencies (explanation at the end). In this case, if we set dedupe-peer-dependents to true, both projects will use the same webpack instance, which is the one that has esbuild resolved:

node_modules
.pnpm
webpack@1.0.0_esbuild@1.0.0
project1
node_modules
webpack -> ../../node_modules/.pnpm/webpack@1.0.0_esbuild@1.0.0/node_modules/webpack
project2
node_modules
webpack -> ../../node_modules/.pnpm/webpack@1.0.0_esbuild@1.0.0/node_modules/webpack
esbuild

What are conflicting peer dependencies? By conflicting peer dependencies we mean a scenario like the following one:

node_modules
.pnpm
webpack@1.0.0_react@16.0.0_esbuild@1.0.0
webpack@1.0.0_react@17.0.0
project1
node_modules
webpack -> ../../node_modules/.pnpm/webpack@1.0.0/node_modules/webpack
react (v17)
project2
node_modules
webpack -> ../../node_modules/.pnpm/webpack@1.0.0_esbuild@1.0.0/node_modules/webpack
esbuild
react (v16)

In this case, we cannot dedupe webpack as webpack has react in its peer dependencies and react is resolved from two different versions in the context of the two projects.

strict-peer-dependencies

  • 기본값: false
  • 유형: Boolean

If this is enabled, commands will fail if there is a missing or invalid peer dependency in the tree.

resolve-peers-from-workspace-root

  • 기본값: true
  • 유형: Boolean

When enabled, dependencies of the root workspace project are used to resolve peer dependencies of any projects in the workspace. It is a useful feature as you can install your peer dependencies only in the root of the workspace, and you can be sure that all projects in the workspace use the same versions of the peer dependencies.

CLI Settings

[no-]color

  • 기본값: auto
  • Type: auto, always, never

Controls colors in the output.

  • auto - output uses colors when the standard output is a terminal or TTY.
  • always - ignore the difference between terminals and pipes. You’ll rarely want this; in most scenarios, if you want color codes in your redirected output, you can instead pass a --color flag to the pnpm command to force it to use color codes. The default setting is almost always what you’ll want.
  • never - turns off colors. This is the setting used by --no-color.

loglevel

  • Default: info
  • Type: debug, info, warn, error

Any logs at or higher than the given level will be shown. You can instead pass --silent to turn off all output logs.

use-beta-cli

  • 기본값: false
  • 유형: Boolean

Experimental option that enables beta features of the CLI. This means that you may get some changes to the CLI functionality that are breaking changes, or potentially bugs.

recursive-install

  • 기본값: true
  • 유형: Boolean

If this is enabled, the primary behaviour of pnpm install becomes that of pnpm install -r, meaning the install is performed on all workspace or subdirectory packages.

Else, pnpm install will exclusively build the package in the current directory.

engine-strict

  • 기본값: false
  • 유형: Boolean

If this is enabled, pnpm will not install any package that claims to not be compatible with the current Node version.

Regardless of this configuration, installation will always fail if a project (not a dependency) specifies an incompatible version in its engines field.

npm-path

  • 유형: path

The location of the npm binary that pnpm uses for some actions, like publishing.

빌드 설정

ignore-scripts

  • 기본값: false
  • 유형: Boolean

Do not execute any scripts defined in the project package.json and its dependencies.

note

This flag does not prevent the execution of .pnpmfile.cjs

ignore-dep-scripts

  • 기본값: false
  • 유형: Boolean

Do not execute any scripts of the installed packages. Scripts of the projects are executed.

child-concurrency

  • Default: 5
  • 유형: Number

The maximum number of child processes to allocate simultaneously to build node_modules.

side-effects-cache

  • 기본값: true
  • 유형: Boolean

Use and cache the results of (pre/post)install hooks.

side-effects-cache-readonly

  • 기본값: false
  • 유형: Boolean

Only use the side effects cache if present, do not create it for new packages.

unsafe-perm

  • Default: false IF running as root, ELSE true
  • 유형: Boolean

Set to true to enable UID/GID switching when running package scripts. If set explicitly to false, then installing as a non-root user will fail.

Node.js Settings

use-node-version

  • Default: undefined
  • Type: semver

Specifies which exact Node.js version should be used for the project's runtime. pnpm will automatically install the specified version of Node.js and use it for running pnpm run commands or the pnpm node command.

This may be used instead of .nvmrc and nvm. Instead of the following .nvmrc file:

16.16.0

Use this .npmrc file:

use-node-version=16.16.0

node-version

  • Default: the value returned by node -v, without the v prefix
  • Type: semver

The Node.js version to use when checking a package's engines setting.

If you want to prevent contributors of your project from adding new incompatible dependencies, use node-version and engine-strict in a .npmrc file at the root of the project:

node-version=12.22.0
engine-strict=true

This way, even if someone is using Node.js v16, they will not be able to install a new dependency that doesn't support Node.js v12.22.0.

node-mirror:<releaseDir>

  • Default: https://nodejs.org/download/<releaseDir>/
  • Type: URL

Sets the base URL for downloading Node.js. The <releaseDir> portion of this setting can be any directory from https://nodejs.org/download: release, rc, nightly, v8-canary, etc.

Here is how pnpm may be configured to download Node.js from Node.js mirror in China:

node-mirror:release=https://npmmirror.com/mirrors/node/
node-mirror:rc=https://npmmirror.com/mirrors/node-rc/
node-mirror:nightly=https://npmmirror.com/mirrors/node-nightly/

Workspace Settings

  • 기본값: true
  • Type: true, false, deep

If this is enabled, locally available packages are linked to node_modules instead of being downloaded from the registry. This is very convenient in a monorepo. If you need local packages to also be linked to subdependencies, you can use the deep setting.

Else, packages are downloaded and installed from the registry. However, workspace packages can still be linked by using the workspace: range protocol.

prefer-workspace-packages

  • 기본값: false
  • 유형: Boolean

If this is enabled, local packages from the workspace are preferred over packages from the registry, even if there is a newer version of the package in the registry.

This setting is only useful if the workspace doesn't use save-workspace-protocol.

shared-workspace-lockfile

  • 기본값: true
  • 유형: Boolean

If this is enabled, pnpm creates a single pnpm-lock.yaml file in the root of the workspace. This also means that all dependencies of workspace packages will be in a single node_modules (and get symlinked to their package node_modules folder for Node's module resolution).

Advantages of this option:

  • every dependency is a singleton
  • faster installations in a monorepo
  • fewer changes in code reviews as they are all in one file
note

Even though all the dependencies will be hard linked into the root node_modules, packages will have access only to those dependencies that are declared in their package.json, so pnpm's strictness is preserved. This is a result of the aforementioned symbolic linking.

save-workspace-protocol

  • Default: rolling
  • Type: true, false, rolling

This setting controls how dependencies that are linked from the workspace are added to package.json.

If foo@1.0.0 is in the workspace and you run pnpm add foo in another project of the workspace, below is how foo will be added to the dependencies field. The save-prefix setting also influences how the spec is created.

save-workspace-protocolsave-prefixspec
false''1.0.0
false'~'~1.0.0
false'^'^1.0.0
true''workspace:1.0.0
true'~'workspace:~1.0.0
true'^'workspace:^1.0.0
rolling''workspace:*
rolling'~'workspace:~
rolling'^'workspace:^

include-workspace-root

  • 기본값: false
  • 유형: Boolean

When executing commands recursively in a workspace, execute them on the root workspace project as well.

ignore-workspace-cycles

Added in: v8.1.0

  • 기본값: false
  • 유형: Boolean

When set to true, no workspace cycle warnings will be printed.

disallow-workspace-cycles

Added in: v8.9.0

  • 기본값: false
  • 유형: Boolean

When set to true, installation will fail if the workspace has cycles.

Other Settings

use-running-store-server

  • 기본값: false
  • 유형: Boolean

Only allows installation with a store server. If no store server is running, installation will fail.

save-prefix

  • Default: '^'
  • Type: '^', '~', ''

Configure how versions of packages installed to a package.json file get prefixed.

For example, if a package has version 1.2.3, by default its version is set to ^1.2.3 which allows minor upgrades for that package, but after pnpm config set save-prefix='~' it would be set to ~1.2.3 which only allows patch upgrades.

This setting is ignored when the added package has a range specified. For instance, pnpm add foo@2 will set the version of foo in package.json to 2, regardless of the value of save-prefix.

tag

  • Default: latest
  • Type: String

If you pnpm add a package and you don't provide a specific version, then it will install the package at the version registered under the tag from this setting.

This also sets the tag that is added to the package@version specified by the pnpm tag command if no explicit tag is given.

global-dir

  • 기본값:
    • If the $XDG_DATA_HOME env variable is set, then $XDG_DATA_HOME/pnpm/global
    • On Windows: ~/AppData/Local/pnpm/global
    • On macOS: ~/Library/pnpm/global
    • On Linux: ~/.local/share/pnpm/global
  • 유형: path

Specify a custom directory to store global packages.

global-bin-dir

  • 기본값:
    • If the $XDG_DATA_HOME env variable is set, then $XDG_DATA_HOME/pnpm
    • On Windows: ~/AppData/Local/pnpm
    • On macOS: ~/Library/pnpm
    • On Linux: ~/.local/share/pnpm
  • 유형: path

Allows to set the target directory for the bin files of globally installed packages.

state-dir

  • 기본값:
    • If the $XDG_STATE_HOME env variable is set, then $XDG_STATE_HOME/pnpm
    • On Windows: ~/AppData/Local/pnpm-state
    • On macOS: ~/.pnpm-state
    • On Linux: ~/.local/state/pnpm
  • 유형: path

The directory where pnpm creates the pnpm-state.json file that is currently used only by the update checker.

cache-dir

  • 기본값:
    • If the $XDG_CACHE_HOME env variable is set, then $XDG_CACHE_HOME/pnpm
    • On Windows: ~/AppData/Local/pnpm-cache
    • On macOS: ~/Library/Caches/pnpm
    • On Linux: ~/.cache/pnpm
  • 유형: path

The location of the package metadata cache.

use-stderr

  • 기본값: false
  • 유형: Boolean

When true, all the output is written to stderr.

update-notifier

  • 기본값: true
  • 유형: Boolean

Set to false to suppress the update notification when using an older version of pnpm than the latest.

prefer-symlinked-executables

  • Default: true, when node-linker is set to hoisted and the system is POSIX
  • 유형: Boolean

Create symlinks to executables in node_modules/.bin instead of command shims. This setting is ignored on Windows, where only command shims work.

verify-store-integrity

  • 기본값: true
  • 유형: Boolean

By default, if a file in the store has been modified, the content of this file is checked before linking it to a project's node_modules. If verify-store-integrity is set to false, files in the content-addressable store will not be checked during installation.

ignore-compatibility-db

  • 기본값: false
  • 유형: Boolean

During installation the dependencies of some packages are automatically patched. If you want to disable this, set this config to false.

The patches are applied from Yarn's @yarnpkg/extensions package.

resolution-mode

  • Default: highest (was lowest-direct from v8.0.0 to v8.6.12)
  • Type: highest, time-based, lowest-direct

When resolution-mode is set to time-based, dependencies will be resolved the following way:

  1. Direct dependencies will be resolved to their lowest versions. So if there is foo@^1.1.0 in the dependencies, then 1.1.0 will be installed.
  2. Subdependencies will be resolved from versions that were published before the last direct dependency was published.

With this resolution mode installations with warm cache are faster. It also reduces the chance of subdependency hijacking as subdependencies will be updated only if direct dependencies are updated.

This resolution mode works only with npm's full metadata. So it is slower in some scenarios. However, if you use Verdaccio v5.15.1 or newer, you may set the registry-supports-time-field setting to true, and it will be really fast.

When resolution-mode is set to lowest-direct, direct dependencies will be resolved to their lowest versions.

registry-supports-time-field

  • 기본값: false
  • 유형: Boolean

Set this to true if the registry that you are using returns the "time" field in the abbreviated metadata. As of now, only Verdaccio from v5.15.1 supports this.

extend-node-path

  • 기본값: true
  • 유형: Boolean

When false, the NODE_PATH environment variable is not set in the command shims.

deploy-all-files

  • 기본값: false
  • 유형: Boolean

When deploying a package or installing a local package, all files of the package are copied. By default, if the package has a "files" field in the package.json, then only the listed files and directories are copied.

dedupe-direct-deps

Added in: v8.1.0

  • 기본값: false
  • 유형: Boolean

When set to true, dependencies that are already symlinked to the root node_modules directory of the workspace will not be symlinked to subproject node_modules directories.

dedupe-injected-deps

Added in: v8.13.1

  • 기본값: false
  • 유형: Boolean

When this setting is enabled, dependencies that are injected will be symlinked from the workspace whenever possible. If the dependent project and the injected dependency reference the same peer dependencies, then it is not necessary to physically copy the injected dependency into the dependent's node_modules; a symlink is sufficient.