Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Version: 10.x

Settings (pnpm-workspace.yaml)

pnpm gets its configuration from the command line, environment variables,pnpm-workspace.yaml, and.npmrc files.

Thepnpm config command can be used to read and edit the contents of the project and global configuration files.

The relevant configuration files are:

  • Per-project configuration file:/path/to/my/project/pnpm-workspace.yaml
  • Global configuration file:~/.config/pnpm/rc (anINI-formatted list ofkey = value parameters)
note

Authorization-related settings are handled by npm's configuration system. So,pnpm config set registry=<value> will actually save the setting to npm's global configuration file.

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

Dependency Resolution

overrides

This field allows you to instruct pnpm to override any dependency in thedependency graph. This is useful for enforcing all your packages to use a singleversion of a dependency, backporting a fix, replacing a dependency with a fork, orremoving an unused dependency.

Note that the overrides field can only be set at the root of the project.

An example of theoverrides field:

overrides:
"foo":"^1.0.0"
"quux":"npm:@myorg/quux@^1.0.0"
"bar@^2.1.0":"3.0.0"
"qar@1>zoo":"2"

You may specify the package the overridden dependency belongs to byseparating the package selector from the dependency selector with a ">", forexampleqar@1>zoo will only override thezoo dependency ofqar@1, not forany other dependencies.

An override may be defined as a reference to a direct dependency's spec.This is achieved by prefixing the name of the dependency with a$:

package.json
{
"dependencies":{
"foo":"^1.0.0"
}
}
pnpm-workspace.yaml
overrides:
foo:"$foo"

The referenced package does not need to match the overridden one:

pnpm-workspace.yaml
overrides:
bar:"$foo"

If you find that your use of a certain package doesn't require one of its dependencies, you may use- to remove it. For example, if packagefoo@1.0.0 requires a large package namedbar for a function that you don't use, removing it could reduce install time:

overrides:
"foo@1.0.0>bar":"-"

This feature is especially useful withoptionalDependencies, where most optional packages can be safely skipped.

packageExtensions

ThepackageExtensions fields offer a way to extend the existing package definitions with additional information. For example, ifreact-redux should havereact-dom in itspeerDependencies but it has not, it is possible to patchreact-redux usingpackageExtensions:

packageExtensions:
react-redux:
peerDependencies:
react-dom:"*"

The keys inpackageExtensions are package names or package names and semver ranges, so it is possible to patch only some versions of a package:

packageExtensions:
react-redux@1:
peerDependencies:
react-dom:"*"

The following fields may be extended usingpackageExtensions:dependencies,optionalDependencies,peerDependencies, andpeerDependenciesMeta.

A bigger example:

packageExtensions:
express@1:
optionalDependencies:
typescript:"2"
fork-ts-checker-webpack-plugin:
dependencies:
"@babel/core":"1"
peerDependencies:
eslint:">= 6"
peerDependenciesMeta:
eslint:
optional:true
tip

Together with Yarn, we maintain a database ofpackageExtensions to patch broken packages in the ecosystem.If you usepackageExtensions, consider sending a PR upstream and contributing your extension to the@yarnpkg/extensions database.

allowedDeprecatedVersions

This setting allows muting deprecation warnings of specific packages.

Example:

allowedDeprecatedVersions:
express:"1"
request:"*"

With the above configuration pnpm will not print deprecation warnings about any version ofrequest and about v1 ofexpress.

updateConfig

updateConfig.ignoreDependencies

Sometimes you can't update a dependency. For instance, the latest version of the dependency started to use ESM but your project is not yet in ESM. Annoyingly, such a package will be always printed out by thepnpm outdated command and updated, when runningpnpm update --latest. However, you may list packages that you don't want to upgrade in theignoreDependencies field:

updateConfig:
ignoreDependencies:
- load-json-file

Patterns are also supported, so you may ignore any packages from a scope:@babel/*.

supportedArchitectures

You can specify architectures for which you'd like to install optional dependencies, even if they don't match the architecture of the system running the install.

For example, the following configuration tells to install optional dependencies for Windows x64:

supportedArchitectures:
os:
- win32
cpu:
- x64

Whereas this configuration will install optional dependencies for Windows, macOS, and the architecture of the system currently running the install. It includes artifacts for both x64 and arm64 CPUs:

supportedArchitectures:
os:
- win32
- darwin
- current
cpu:
- x64
- arm64

Additionally,supportedArchitectures also supports specifying thelibc of the system.

ignoredOptionalDependencies

If an optional dependency has its name included in this array, it will be skipped. For example:

ignoredOptionalDependencies:
- fsevents
-"@esbuild/*"

Dependency Hoisting Settings

hoist

  • Default:true
  • Type:boolean

Whentrue, all dependencies are hoisted tonode_modules/.pnpm/node_modules. This makesunlisted dependencies accessible to all packages insidenode_modules.

hoistWorkspacePackages

  • Default:true
  • Type:boolean

Whentrue, 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 (hoistPattern andpublicHoistPattern).

hoistPattern

  • Default:['*']
  • Type:string[]

Tells pnpm which packages should be hoisted tonode_modules/.pnpm/node_modules. Bydefault, all packages are hoisted - however, if you know that only some flawedpackages have phantom dependencies, you can use this option to exclusively hoistthe phantom dependencies (recommended).

For instance:

hoistPattern:
-"*eslint*"
-"*babel*"

You may also exclude patterns from hoisting using!.

For instance:

hoistPattern:
-"*types*"
-"!@types/react"

publicHoistPattern

  • Default:[]
  • Type:string[]

UnlikehoistPattern, which hoists dependencies to a hidden modules directoryinside the virtual store,publicHoistPattern hoists dependencies matchingthe pattern to the root modules directory. Hoisting to the root modulesdirectory means that application code will have access to phantom dependencies,even if they modify the resolution strategy improperly.

This setting is useful when dealing with some flawed pluggable tools that don'tresolve dependencies properly.

For instance:

publicHoistPattern:
-"*plugin*"

Note: SettingshamefullyHoist totrue is the same as settingpublicHoistPattern to*.

You may also exclude patterns from hoisting using!.

For instance:

publicHoistPattern:
-"*types*"
-"!@types/react"

shamefullyHoist

  • Default:false
  • Type:Boolean

By default, pnpm creates a semistrictnode_modules, meaning dependencies haveaccess to undeclared dependencies but modules outside ofnode_modules do not.With this layout, most of the packages in the ecosystem work with no issues.However, if some tooling only works when the hoisted dependencies are in theroot ofnode_modules, you can set this totrue to hoist them for you.

Node-Modules Settings

modulesDir

  • Default:node_modules
  • Type:path

The directory in which dependencies will be installed (instead ofnode_modules).

nodeLinker

  • Default:isolated
  • Type:isolated,hoisted,pnp

Defines what linker should be used for installing Node packages.

  • isolated - dependencies are symlinked from a virtual store atnode_modules/.pnpm.
  • hoisted - a flatnode_modules without symlinks is created. Same as thenode_modules created by npm or Yarn Classic. One of Yarn's libraries is used for hoisting, when this setting is used. Legitimate reasons to use this setting:
    1. Your tooling doesn't work well with symlinks. A React Native project will most probably only work if you use a hoistednode_modules.
    2. Your project is deployed to a serverless hosting provider. Some serverless providers (for instance, AWS Lambda) don't support symlinks. An alternative solution for this problem is to bundle your application before deployment.
    3. If you want to publish your package with"bundledDependencies".
    4. If you are running Node.js with the--preserve-symlinks flag.
  • pnp - nonode_modules. Plug'n'Play is an innovative strategy for Node that isused by Yarn Berry. It is recommended to also setsymlink setting tofalse when usingpnp asyour linker.

symlink

  • Default:true
  • Type:Boolean

Whensymlink is set tofalse, pnpm creates a virtual store directory withoutany symlinks. It is a useful setting together withnodeLinker=pnp.

enableModulesDir

  • Default:true
  • Type:Boolean

Whenfalse, pnpm will not write any files to the modules directory(node_modules). This is useful for when the modules directory is mounted withfilesystem in userspace (FUSE). There is an experimental CLI that allows you tomount a modules directory with FUSE:@pnpm/mount-modules.

virtualStoreDir

  • Default:node_modules/.pnpm
  • Types:path

The directory with links to the store. All direct and indirect dependencies ofthe project are linked into this directory.

This is a useful setting that can solve issues with long paths on Windows. Ifyou have some dependencies with very long paths, you can select a virtual storein the root of your drive (for instanceC:\my-project-store).

Or you can set the virtual store to.pnpm and add it to.gitignore. Thiswill make stacktraces cleaner as paths to dependencies will be one directoryhigher.

NOTE: the virtual store cannot be shared between several projects. Everyproject should have its own virtual store (except for in workspaces where theroot is shared).

virtualStoreDirMaxLength

  • Default:
    • On Linux/macOS:120
    • On Windows:60
  • Types:number

Sets the maximum allowed length of directory names inside the virtual store directory (node_modules/.pnpm). You may set this to a lower number if you encounter long path issues on Windows.

packageImportMethod

  • Default:auto
  • Type:auto,hardlink,copy,clone,clone-or-copy

Controls the way packages are imported from the store (if you want to disable symlinks insidenode_modules, then you need to change thenodeLinker setting, not this one).

  • auto - try to clone packages from the store. If cloning is not supportedthen hardlink packages from the store. If neither cloning nor linking ispossible, fall back to copying
  • hardlink - hard link packages from the store
  • clone-or-copy - try to clone packages from the store. If cloning is not supported then fall back to copying
  • copy - copy packages from the store
  • clone - clone (AKA copy-on-write or reference link) packages from the store

Cloning is the best way to write packages to node_modules. It is the fastest way and safest way. When cloning is used, you may edit files in your node_modules and they will not be modified in the central content-addressable store.

Unfortunately, not all file systems support cloning. We recommend using a copy-on-write (CoW) file system (for instance, Btrfs instead of Ext4 on Linux) for the best experience with pnpm.

modulesCacheMaxAge

  • Default:10080 (7 days in minutes)
  • Type:number

The time in minutes after which orphan packages from the modules directory should be removed.pnpm keeps a cache of packages in the modules directory. This boosts installation speed whenswitching branches or downgrading dependencies.

dlxCacheMaxAge

  • Default:1440 (1 day in minutes)
  • Type:number

The time in minutes after which dlx cache expires.After executing a dlx command, pnpm keeps a cache that omits the installation step for subsequent calls to the same dlx command.

enableGlobalVirtualStore

Added in: v10.12.1

  • Default:false (alwaysfalse in CI)
  • Type:Boolean
  • Status:Experimental

When enabled,node_modules contains only symlinks to a central virtual store, rather than tonode_modules/.pnpm. By default, this central store is located at<store-path>/links (usepnpm store path to find<store-path>).

In the central virtual store, each package is hard linked into a directory whose name is the hash of its dependency graph. As a result, all projects on the system can symlink their dependencies from this shared location on disk. This approach is conceptually similar to howNixOS manages packages, using dependency graph hashes to create isolated and shareable package directories in the Nix store.

This should not be confused with the global content-addressable store. The actual package files are still hard linked from the content-addressable store—but instead of being linked directly intonode_modules/.pnpm, they are linked into the global virtual store.

Using a global virtual store can significantly speed up installations when a warm cache is available. However, in CI environments (where caches are typically absent), it may slow down installation. If pnpm detects that it is running in CI, this setting is automatically disabled.

important

To support hoisted dependencies when using a global virtual store, pnpm relies on theNODE_PATH environment variable. This allows Node.js to resolve packages from the hoistednode_modules directory. However,this workaround does not work with ESM modules, because Node.js no longer respectsNODE_PATH when using ESM.

If your dependencies are ESM and they import packagesnot declared in their ownpackage.json (which is considered bad practice), you’ll likely run into resolution errors. There are two ways to fix this:

  • UsepackageExtensions to explicitly add the missing dependencies.
  • Add the@pnpm/plugin-esm-node-path config dependency to your project. This plugin registers a custom ESM loader that restoresNODE_PATH support for ESM, allowing hoisted dependencies to be resolved correctly.

Store Settings

storeDir

  • Default:
    • If the$PNPM_HOME env variable is set, then$PNPM_HOME/store
    • If the$XDG_DATA_HOME env variable is set, then$XDG_DATA_HOME/pnpm/store
    • On Windows:~/AppData/Local/pnpm/store
    • On macOS:~/Library/pnpm/store
    • On Linux:~/.local/share/pnpm/store
  • Type:path

The location where all the packages are saved on the disk.

The store should be always on the same disk on which installation is happening,so there will be one store per disk. If there is a home directory on the currentdisk, then the store is created inside it. If there is no home on the disk,then the store is created at the root of the filesystem. Forexample, if installation is happening on a filesystem mounted at/mnt,then the store will be created at/mnt/.pnpm-store. The same goes for Windowssystems.

It is possible to set a store from a different disk but in that case pnpm willcopy packages from the store instead of hard-linking them, as hard links areonly possible on the same filesystem.

verifyStoreIntegrity

  • Default:true
  • Type: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'snode_modules. IfverifyStoreIntegrity is set tofalse, files in the content-addressable store will not be checked during installation.

useRunningStoreServer

danger

Deprecated feature

  • Default:false
  • Type:Boolean

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

strictStorePkgContentCheck

  • Default:true
  • Type:Boolean

Some registries allow the exact same content to be published under different package names and/or versions. This breaks the validity checks of packages in the store. To avoid errors when verifying the names and versions of such packages in the store, you may set thestrictStorePkgContentCheck setting tofalse.

Lockfile Settings

lockfile

  • Default:true
  • Type:Boolean

When set tofalse, pnpm won't read or generate apnpm-lock.yaml file.

preferFrozenLockfile

  • Default:true
  • Type:Boolean

When set totrue and the availablepnpm-lock.yaml satisfies thepackage.json dependencies directive, a headless installation is performed. Aheadless installation skips all dependency resolution as it does not need tomodify the lockfile.

lockfileIncludeTarballUrl

  • Default:false
  • Type:Boolean

Add the full URL to the package's tarball to every entry inpnpm-lock.yaml.

gitBranchLockfile

  • Default:false
  • Type:Boolean

When set totrue, the generated lockfile name after installation will be namedbased on the current branch name to completely avoid merge conflicts. For example,if the current branch name isfeature-foo, the corresponding lockfile name willbepnpm-lock.feature-foo.yaml instead ofpnpm-lock.yaml. It is typically usedin conjunction with the command line argument--merge-git-branch-lockfiles or bysettingmergeGitBranchLockfilesBranchPattern in thepnpm-workspace.yaml file.

mergeGitBranchLockfilesBranchPattern

  • Default:null
  • Type:Array or null

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

For instance:

mergeGitBranchLockfilesBranchPattern:
- main
- release*

You may also exclude patterns using!.

peersSuffixMaxLength

  • Default:1000
  • Type:number

Max length of the peer IDs suffix added to dependency keys in the lockfile. If the suffix is longer, it is replaced with a hash.

Registry & Authentication Settings

registry

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

<scope>:registry

The npm registry that should be used for packages of the specified scope. Forexample, setting@babel:registry=https://example.com/packages/npm/will enforce that when you usepnpm add @babel/core, or any@babel scopedpackage, the package will be fetched fromhttps://example.com/packages/npminstead of the default registry.

<URL>:_authToken

Define the authentication bearer token to use when accessing the specifiedregistry. 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 SSLconnections 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 trustonly that specific signing authority.

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

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

See also thestrict-ssl config.

cafile

  • Default:null
  • Type:path

A path to a file containing one or multiple Certificate Authority signingcertificates. Similar to theca setting, but allows for multiple CAs, as wellas for the CA information to be stored in a file instead of being specified viaCLI.

<URL>:cafile

Define the path to a Certificate Authority file to use when accessing the specifiedregistry. For example:

//registry.npmjs.org/:cafile=ca-cert.pem

cert

  • Default:null
  • Type:String

A client certificate to pass when accessing the registry. Values should be inPEM 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.

<URL>:certfile

Define the path to a certificate file to use when accessing the specifiedregistry. For example:

//registry.npmjs.org/:certfile=server-cert.pem

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 nokeyfile option).

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

<URL>:keyfile

Define the path to a client key file to use when accessing the specifiedregistry. For example:

//registry.npmjs.org/:keyfile=server-key.pem

gitShallowHosts

  • Default:['github.com', 'gist.github.com', 'gitlab.com', 'bitbucket.com', 'bitbucket.org']
  • Type: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
  • Type:url

A proxy to use for outgoing HTTPS requests. If theHTTPS_PROXY,https_proxy,HTTP_PROXY orhttp_proxy environment variables are set, their values will beused instead.

If your proxy URL contains a username and password, make sure to URL-encode them.For instance:

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
  • Type:url

A proxy to use for outgoing http requests. If the HTTP_PROXY or http_proxyenvironment variables are set, proxy settings will be honored by the underlyingrequest library.

local-address

  • Default:undefined
  • Type:IP Address

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

maxsockets

  • Default:networkConcurrency x 3
  • Type: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

  • Default:true
  • Type:Boolean

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

See also theca option.

networkConcurrency

  • Default:16
  • Type:Number

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

fetchRetries

  • Default:2
  • Type:Number

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

fetchRetryFactor

  • Default:10
  • Type:Number

The exponential factor for retry backoff.

fetchRetryMintimeout

  • Default:10000 (10 seconds)
  • Type:Number

The minimum (base) timeout for retrying requests.

fetchRetryMaxtimeout

  • Default:60000 (1 minute)
  • Type:Number

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

fetchTimeout

  • Default:60000 (1 minute)
  • Type:Number

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

Peer Dependency Settings

autoInstallPeers

  • Default:true
  • Type:Boolean

Whentrue, 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 requiresreact@^16.0.0 and another requiresreact@^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.

dedupePeerDependents

  • Default:true
  • Type:Boolean

When this setting is set totrue, 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 havewebpack in their dependencies.webpack hasesbuild in its optional peer dependencies, and one of the projects hasesbuild in its dependencies. In this case, pnpm will link two instances ofwebpack to thenode_modules/.pnpm directory: one withesbuild 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 becausewebpack is used in two projects, and one of the projects doesn't haveesbuild, so the two projects cannot share the same instance ofwebpack. However, this is not what most developers expect, especially since in a hoistednode_modules, there would only be one instance ofwebpack. Therefore, you may now use thededupePeerDependents setting to deduplicatewebpack when it has no conflicting peer dependencies (explanation at the end). In this case, if we setdedupePeerDependents totrue, both projects will use the samewebpack instance, which is the one that hasesbuild 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 dedupewebpack aswebpack hasreact in its peer dependencies andreact is resolved from two different versions in the context of the two projects.

strictPeerDependencies

  • Default:false
  • Type:Boolean

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

resolvePeersFromWorkspaceRoot

  • Default:true
  • Type: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.

peerDependencyRules

peerDependencyRules.ignoreMissing

pnpm will not print warnings about missing peer dependencies from this list.

For instance, with the following configuration, pnpm will not print warnings if a dependency needsreact butreact is not installed:

peerDependencyRules:
ignoreMissing:
- react

Package name patterns may also be used:

peerDependencyRules:
ignoreMissing:
-"@babel/*"
-"@eslint/*"

peerDependencyRules.allowedVersions

Unmet peer dependency warnings will not be printed for peer dependencies of the specified range.

For instance, if you have some dependencies that needreact@16 but you know that they work fine withreact@17, then you may use the following configuration:

peerDependencyRules:
allowedVersions:
react:"17"

This will tell pnpm that any dependency that has react in its peer dependencies should allowreact v17 to be installed.

It is also possible to suppress the warnings only for peer dependencies of specific packages. For instance, with the following configurationreact v17 will be only allowed when it is in the peer dependencies of thebutton v2 package or in the dependencies of anycard package:

peerDependencyRules:
allowedVersions:
"button@2>react":"17",
"card>react":"17"

peerDependencyRules.allowAny

allowAny is an array of package name patterns, any peer dependency matching the pattern will be resolved from any version, regardless of the range specified inpeerDependencies. For instance:

peerDependencyRules:
allowAny:
-"@babel/*"
-"eslint"

The above setting will mute any warnings about peer dependency version mismatches related to@babel/ packages oreslint.

CLI Settings

[no-]color

  • Default: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 rarelywant this; in most scenarios, if you want color codes in your redirectedoutput, you can instead pass a--color flag to the pnpm command to force itto 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.

useBetaCli

  • Default:false
  • Type:Boolean

Experimental option that enables beta features of the CLI. This means that youmay get some changes to the CLI functionality that are breaking changes, orpotentially bugs.

recursiveInstall

  • Default:true
  • Type:Boolean

If this is enabled, the primary behaviour ofpnpm install becomes that ofpnpm install -r, meaning the install is performed on all workspace orsubdirectory packages.

Else,pnpm install will exclusively build the package in the currentdirectory.

engineStrict

  • Default:false
  • Type:Boolean

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

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

npmPath

  • Type:path

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

packageManagerStrict

  • Default:true
  • Type:Boolean

If this setting is disabled, pnpm will not fail if a different package manager is specified in thepackageManager field ofpackage.json. When enabled, only the package name is checked (since pnpm v9.2.0), so you can still run any version of pnpm regardless of the version specified in thepackageManager field.

Alternatively, you can disable this setting by setting theCOREPACK_ENABLE_STRICT environment variable to0.

packageManagerStrictVersion

  • Default:false
  • Type:Boolean

When enabled, pnpm will fail if its version doesn't exactly match the version specified in thepackageManager field ofpackage.json.

managePackageManagerVersions

  • Default:true
  • Type:Boolean

When enabled, pnpm will automatically download and run the version of pnpm specified in thepackageManager field ofpackage.json. This is the same field used by Corepack. Example:

{
"packageManager":"pnpm@9.3.0"
}

Build Settings

ignoreScripts

  • Default:false
  • Type:Boolean

Do not execute any scripts defined in the projectpackage.json and itsdependencies.

note

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

ignoreDepScripts

  • Default:false
  • Type:Boolean

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

note

Since v10, pnpm doesn't run the lifecycle scripts of dependencies unless they are listed inonlyBuiltDependencies.

childConcurrency

  • Default:5
  • Type:Number

The maximum number of child processes to allocate simultaneously to buildnode_modules.

sideEffectsCache

  • Default:true
  • Type:Boolean

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

When a pre/post install script modify the contents of a package (e.g. build output), pnpm saves the modified package in the global store. On future installs on the same machine, pnpm reuses this cached, prebuilt version—making installs significantly faster.

note

You may want to disable this setting if:

  1. The install scripts modify filesoutside the package directory (pnpm cannot track or cache these changes).
  2. The scripts perform side effects that are unrelated to building the package.

sideEffectsCacheReadonly

  • Default:false
  • Type:Boolean

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

unsafePerm

  • Default:false IF running as root, ELSEtrue
  • Type: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.

nodeOptions

  • Default:NULL
  • Type:String

Options to pass through to Node.js via theNODE_OPTIONS environment variable. This does not impact how pnpm itself is executed but it does impact how lifecycle scripts are called.

To preserve existingNODE_OPTIONS you can reference the existing environment variable using${NODE_OPTIONS} in your configuration:

nodeOptions:"${NODE_OPTIONS:- } --experimental-vm-modules"

verifyDepsBeforeRun

  • Default:false
  • Type:install,warn,error,prompt,false

This setting allows the checking of the state of dependencies before running scripts. The check runs onpnpm run andpnpm exec commands. The following values are supported:

  • install - Automatically runs install ifnode_modules is not up to date.
  • warn - Prints a warning ifnode_modules is not up to date.
  • prompt - Prompts the user for permission to run install ifnode_modules is not up to date.
  • error - Throws an error ifnode_modules is not up to date.
  • false - Disables dependency checks.

strictDepBuilds

Added in: v10.3.0

  • Default:false
  • Type:Boolean

WhenstrictDepBuilds is enabled, the installation will exit with a non-zero exit code if any dependencies have unreviewed build scripts (aka postinstall scripts).

neverBuiltDependencies

This field allows to ignore the builds of specific dependencies.The "preinstall", "install", and "postinstall" scripts of the listed packages will not be executed during installation.

An example of theneverBuiltDependencies field:

neverBuiltDependencies:
- fsevents
- level

onlyBuiltDependencies

A list of package names that are allowed to be executed during installation. Only packages listed in this array will be able to run install scripts. IfonlyBuiltDependenciesFile andneverBuiltDependencies are not set, this configuration option will default to blocking all install scripts.

Example:

onlyBuiltDependencies:
- fsevents

onlyBuiltDependenciesFile

This configuration option allows users to specify a JSON file that lists the only packages permitted to run installation scripts during the pnpm install process. By using this, you can enhance security or ensure that only specific dependencies execute scripts during installation.

Example:

configDependencies:
'@pnpm/trusted-deps': 0.1.0+sha512-IERT0uXPBnSZGsCmoSuPzYNWhXWWnKkuc9q78KzLdmDWJhnrmvc7N4qaHJmaNKIusdCH2riO3iE34Osohj6n8w==
onlyBuiltDependenciesFile: node_modules/.pnpm-config/@pnpm/trusted-deps/allow.json

The JSON file itself should contain an array of package names:

node_modules/.pnpm-config/@pnpm/trusted-deps/allow.json
[
"@airbnb/node-memwatch",
"@apollo/protobufjs",
...
]

ignoredBuiltDependencies

Added in: v10.1.0

A list of package names that should not be built during installation.

Example:

ignoredBuiltDependencies:
- fsevents

dangerouslyAllowAllBuilds

Added in: v10.9.0

  • Default:false
  • Type:Boolean

If set totrue, all build scripts (e.g.preinstall,install,postinstall) from dependencies will run automatically, without requiring approval.

warning

This setting allows all dependencies—including transitive ones—to run install scripts, both now and in the future.Even if your current dependency graph appears safe:

  • Future updates may introduce new, untrusted dependencies.
  • Existing packages may add scripts in later versions.
  • Packages can be hijacked or compromised and begin executing malicious code.

For maximum safety, only enable this if you’re fully aware of the risks and trust the entire ecosystem you’re pulling from. It’s recommended to review and allow builds explicitly.

Node.js Settings

useNodeVersion

  • 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 forrunningpnpm run commands or thepnpm node command.

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

16.16.0

Use thispnpm-workspace.yaml file:

useNodeVersion: 16.16.0

This setting works only in apnpm-workspace.yaml file that is in the root of your workspace. If you need to specify a custom Node.js for a project in the workspace, use theexecutionEnv.nodeVersion field ofpackage.json instead.

nodeVersion

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

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

If you want to prevent contributors of your project from adding new incompatible dependencies, usenodeVersion andengineStrict in apnpm-workspace.yaml file at the root of the project:

nodeVersion: 12.22.0
engineStrict: 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

  • 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 fromhttps://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/

executionEnv.nodeVersion

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 forrunningpnpm run commands or thepnpm node command.

For example:

executionEnv:
nodeVersion:16.16.0

Workspace Settings

linkWorkspacePackages

  • Default:false
  • Type:true,false,deep

If this is enabled, locally available packages are linked tonode_modulesinstead of being downloaded from the registry. This is very convenient in amonorepo. If you need local packages to also be linked to subdependencies, youcan use thedeep setting.

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

Packages are only linked if their versions satisfy the dependency ranges.

injectWorkspacePackages

  • Default:false
  • Type:Boolean

Enables hard-linking of all local workspace dependencies instead of symlinking them. Alternatively, this can be achieved usingdependenciesMeta[].injected, which allows to selectively enable hard-linking for specific dependencies.

note

Even if this setting is enabled, pnpm will prefer to deduplicate injected dependencies using symlinks—unless multiple dependency graphs are required due to mismatched peer dependencies. This behaviour is controlled by thededupeInjectedDeps setting.

dedupeInjectedDeps

  • Default:true
  • Type: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'snode_modules; a symlink is sufficient.

syncInjectedDepsAfterScripts

Added in: v10.5.0

  • Default:undefined
  • Type:String[]

Injected workspace dependencies are collections of hardlinks, which don't add or remove the files when their sources change. This causes problems in packages that need to be built (such as in TypeScript projects).

This setting is a list of script names. When any of these scripts are executed in a workspace package, the injected dependencies insidenode_modules will also be synchronized.

preferWorkspacePackages

  • Default:false
  • Type:Boolean

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

This setting is only useful if the workspace doesn't usesaveWorkspaceProtocol.

sharedWorkspaceLockfile

  • Default:true
  • Type:Boolean

If this is enabled, pnpm creates a singlepnpm-lock.yaml file in the root ofthe workspace. This also means that all dependencies of workspace packages willbe in a singlenode_modules (and get symlinked to their packagenode_modulesfolder 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 rootnode_modules, packages will have access only to those dependenciesthat are declared in theirpackage.json, so pnpm's strictness is preserved.This is a result of the aforementioned symbolic linking.

saveWorkspaceProtocol

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

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

Iffoo@1.0.0 is in the workspace and you runpnpm add foo in another project of the workspace, below is howfoo will be added to the dependencies field. ThesavePrefix setting also influences how the spec is created.

saveWorkspaceProtocolsavePrefixspec
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:^

includeWorkspaceRoot

  • Default:false
  • Type:Boolean

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

ignoreWorkspaceCycles

  • Default:false
  • Type:Boolean

When set totrue, no workspace cycle warnings will be printed.

disallowWorkspaceCycles

  • Default:false
  • Type:Boolean

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

Deploy Settings

forceLegacyDeploy

  • Default:false
  • Type:Boolean

By default,pnpm deploy will try creating a dedicated lockfile from a shared lockfile for deployment. If this setting is set totrue, the legacydeploy behavior will be used.

Patching Dependencies

patchedDependencies

This field is added/updated automatically when you runpnpm patch-commit. It defines patches for dependencies using a dictionary where:

  • Keys: Package names with an exact version, a version range, or just the name.
  • Values: Relative paths to patch files.

Example:

patchedDependencies:
express@4.18.1: patches/express@4.18.1.patch

Dependencies can be patched by version range. The priority order is:

  1. Exact versions (highest priority)
  2. Version ranges
  3. Name-only patches (applies to all versions unless overridden)

A special case: the version range* behaves like a name-only patch but does not ignore patch failures.

Exampe:

patchedDependencies:
foo: patches/foo-1.patch
foo@^2.0.0: patches/foo-2.patch
foo@2.1.0: patches/foo-3.patch
  • patches/foo-3.patch is applied tofoo@2.1.0.
  • patches/foo-2.patch applies to all foo versions matching^2.0.0, except2.1.0.
  • patches/foo-1.patch applies to all other foo versions.

Avoid overlapping version ranges. If you need to specialize a sub-range, explicitly exclude it from the broader range.

Example:

patchedDependencies:
# Specialized sub-range
"foo@2.2.0-2.8.0": patches/foo.2.2.0-2.8.0.patch
# General patch, excluding the sub-range above
"foo@>=2.0.0 <2.2.0 || >2.8.0": patches/foo.gte2.patch

In most cases, defining an exact version is enough to override a broader range.

allowUnusedPatches

Added in: v10.7.0 (Previously namedallowNonAppliedPatches)

  • Default:false
  • Type:Boolean

Whentrue, installation won't fail if some of the patches from thepatchedDependencies field were not applied.

patchedDependencies:
express@4.18.1: patches/express@4.18.1.patch
allowUnusedPatches:true

ignorePatchFailures

Added in: v10.7.0

  • Default:undefined
  • Type:Boolean,undefined

Controls how patch failures are handled.

Behaviour:

  • undefined (default):
    • Errors out when a patch with an exact version or version range fails.
    • Ignores failures from name-only patches.
  • false: Errors out for any patch failure.
  • true: Prints a warning instead of failing when any patch cannot be applied.

Audit Settings

auditConfig

auditConfig.ignoreCves

A list of CVE IDs that will be ignored by thepnpm audit command.

auditConfig:
ignoreCves:
- CVE-2022-36313

auditConfig.ignoreGhsas

A list of GHSA Codes that will be ignored by thepnpm audit command.

auditConfig:
ignoreGhsas:
- GHSA-42xw-2xvc-qx8m
- GHSA-4w2v-q235-vp99
- GHSA-cph5-m8f7-6c5x
- GHSA-vh95-rmgr-6w4m

Pnpmfile

ignorePnpmfile

  • Default:false
  • Type:Boolean

.pnpmfile.cjs will be ignored. Useful together with--ignore-scripts when youwant to make sure that no script gets executed during install.

pnpmfile

  • Default:['.pnpmfile.cjs']
  • Type:path[]
  • Example:['.pnpm/.pnpmfile.cjs']

The location of the local pnpmfile(s).

globalPnpmfile

  • Default:null
  • Type:path
  • Example:~/.pnpm/global_pnpmfile.cjs

The location of a global pnpmfile. A global pnpmfile is used by all projectsduring installation.

note

It is recommended to use local pnpmfiles. Only use a global pnpmfileif you use pnpm on projects that don't use pnpm as the primary package manager.

Other Settings

savePrefix

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

Configure how versions of packages installed to apackage.json file getprefixed.

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

This setting is ignored when the added package has a range specified. Forinstance,pnpm add foo@2 will set the version offoo inpackage.json to2, regardless of the value ofsavePrefix.

tag

  • Default:latest
  • Type:String

If youpnpm add a package and you don't provide a specific version, then itwill install the package at the version registered under the tag from thissetting.

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

globalDir

  • Default:
    • 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
  • Type:path

Specify a custom directory to store global packages.

globalBinDir

  • Default:
    • 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
  • Type:path

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

stateDir

  • Default:
    • 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
  • Type:path

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

cacheDir

  • Default:
    • 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
  • Type:path

The location of the cache (package metadata and dlx).

useStderr

  • Default:false
  • Type:Boolean

When true, all the output is written to stderr.

updateNotifier

  • Default:true
  • Type:Boolean

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

preferSymlinkedExecutables

  • Default:true, whennode-linker is set tohoisted and the system is POSIX
  • Type:Boolean

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

ignoreCompatibilityDb

  • Default:false
  • Type:Boolean

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

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

resolutionMode

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

WhenresolutionMode is set totime-based, dependencies will be resolved the following way:

  1. Direct dependencies will be resolved to their lowest versions. So if there isfoo@^1.1.0 in the dependencies, then1.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'sfull metadata. So it is slower in some scenarios. However, if you useVerdaccio v5.15.1 or newer, you may set theregistrySupportsTimeField setting totrue, and it will be really fast.

WhenresolutionMode is set tolowest-direct, direct dependencies will be resolved to their lowest versions.

registrySupportsTimeField

  • Default:false
  • Type:Boolean

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

extendNodePath

  • Default:true
  • Type:Boolean

Whenfalse, theNODE_PATH environment variable is not set in the command shims.

deployAllFiles

  • Default:false
  • Type: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 thepackage.json, then only the listed files and directories are copied.

dedupeDirectDeps

  • Default:false
  • Type:Boolean

When set totrue, dependencies that are already symlinked to the rootnode_modules directory of the workspace will not be symlinked to subprojectnode_modules directories.

optimisticRepeatInstall

Added in: v10.1.0

  • Default:true
  • Type:Boolean

When enabled, a fast check will be performed before proceeding to installation. This way a repeat install or an install on a project with everything up-to-date becomes a lot faster.

requiredScripts

Scripts listed in this array will be required in each project of the workspace. Otherwise,pnpm -r run <script name> will fail.

requiredScripts:
- build

enablePrePostScripts

  • Default:true
  • Type:Boolean

Whentrue, pnpm will run any pre/post scripts automatically. So runningpnpm foowill be like runningpnpm prefoo && pnpm foo && pnpm postfoo.

scriptShell

  • Default:null
  • Type:path

The shell to use for scripts run with thepnpm run command.

For instance, to force usage of Git Bash on Windows:

pnpm config set scriptShell "C:\\Program Files\\git\\bin\\bash.exe"

shellEmulator

  • Default:false
  • Type:Boolean

Whentrue, pnpm will use a JavaScript implementation of abash-like shell toexecute scripts.

This option simplifies cross-platform scripting. For instance, by default, thenext script will fail on non-POSIX-compliant systems:

"scripts":{
"test":"NODE_ENV=test node test.js"
}

But if theshellEmulator setting is set totrue, it will work on allplatforms.

catalogMode

Added in: v10.12.1

  • Default:manual
  • Type:manual,strict,prefer

Controlls if and how dependencies are added to the default catalog, when runningpnpm add. There are three modes:

  • strict - only allows dependency versions from the catalog. Adding a dependency outside the catalog's version range will cause an error.
  • prefer - prefers catalog versions, but will fall back to direct dependencies if no compatible version is found.
  • manual (default) - does not automatically add dependencies to the catalog.

ci

Added in: v10.12.1

  • Default:true (when the environment is detected as CI)
  • Type:Boolean

This setting explicitly tells pnpm whether the current environment is a CI (Continuous Integration) environment.


[8]ページ先頭

©2009-2025 Movatter.jp