Movatterモバイル変換


[0]ホーム

URL:


Passer au contenu principal
Ceci est la documentation de pnpm8.x, qui n'est plus activement maintenue.
Pour une documentation à jour, consultez ladernière version (10.x).
Version : 8.x

.npmrc

pnpm obtient sa configuration à partir de la ligne de commande, des variables d'environnement et des fichiers.npmrc.

La commandepnpm config peut être utilisée pour mettre à jour et modifier le contenu des fichiers.npmrc utilisateur et global.

Les quatre fichiers concernés sont:

  • fichier de configuration par projet (/chemin/jusque/vers/mon/projet/.npmrc)
  • fichier de configuration par espace de travail (le dossier qui contient le fichierpnpm-workspace.yaml)
  • fichier de configuration par utilisateur (~/.npmrc)
  • fichier de configuration global (/etc/npmrc)

Tous les fichiers.npmrc sont une liste de paramètresclé = valeur auformat INI.

Les valeurs dans les fichiers.npmrc peuvent contenir des variables env en utilisant la syntaxe${NAME}. Les variables env peuvent également être spécifiées avec les valeurs par défaut. L'utilisation de${NAME-fallback} retournera fallback siNOM n'est pas défini.${NAME:-fallback} will returnfallback ifNAME isn't set, or is an empty string.

Paramètres de hoisting des dépendances

hoist

  • Par défaut:true
  • Type:boolean

Quandtrue est mis, toutes les dépendances sont hissées aunode_modules/.pnpm/node_modules. Cela rend des dépendances non listées accessibles à tous les paquets à l'intérieur denode_modules.

hoist-workspace-packages

Added in: v8.14.0

  • Par défaut:false
  • 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 (hoist-pattern andpublic-hoist-pattern).

hoist-pattern

  • Par défaut:['*']
  • Type:boolean

Indique à pnpm quels paquets doivent être hissés surnode_modules/.pnpm/node_modules. Par par défaut, tous les paquets sont hissés - cependant, si vous savez que seuls quelques paquets imparfaits ont des dépendances fantômes, vous pouvez utiliser cette option pour hisser exclusivement les dépendances fantômes (recommandé).

Par exemple :

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

You may also exclude patterns from hoisting using!.

Par exemple :

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

public-hoist-pattern

  • Default:['*eslint*', '*prettier*']
  • Type:boolean

Contrairement auhoist-pattern, qui héberge les dépendances dans un répertoire de modules cachés dans la boutique virtuelle,public-hoist-pattern hisse les dépendances associant le patron au répertoire des modules racine. Le répertoire des modules racine signifie que le code de l'application aura accès aux dépendances fantômes, même s'ils modifient incorrectement la stratégie de résolution.

Ce paramètre est utile pour gérer certains outils branchés défectueux qui ne résolvent pas correctement les dépendances.

Par exemple :

public-hoist-pattern[]=*plugin*

Remarque : Le réglagehonteusement hissé àtrue est le même que le réglagepublic-hoist-pattern à*.

You may also exclude patterns from hoisting using!.

Par exemple :

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

shamefully-hoist

  • Par défaut:false
  • Type:Boolean

Par défaut, pnpm crée un nœud semi-strictnode_modules, ce qui signifie que les dépendances ont accès aux dépendances non déclarées, mais pas les modules en dehors denode_modules. Avec cette mise en page, la plupart des paquets de l'écosystème fonctionnent sans problème. Cependant, si certains outils ne fonctionnent que lorsque les dépendances hissées sont à la racine denode_modules, vous pouvez définir ceci àtrue pour les hisser pour vous.

Paramètres des modules de nœud

store-dir

  • Par défaut:
    • If the$PNPM_HOME env variable is set, then$PNPM_HOME/store
    • Si la variable env$XDG_DATA_HOME est définie, alors$XDG_DATA_HOME/pnpm/store
    • Sous Windows :~/AppData/Local/pnpm/store
    • Sur macOS:~/Library/pnpm/store
    • Sous Linux :~/.local/share/pnpm/store
  • Type:chemin

L'emplacement où tous les paquets sont enregistrés sur le disque.

La boutique devrait toujours être sur le même disque sur lequel se déroule l'installation, donc il y aura un magasin par disque. S'il y a un répertoire personnel sur le disque courant, alors le magasin est créé à l'intérieur. S'il n'y a pas de maison sur le disque, alors le stockage est créé à la racine du système de fichiers. Par exemple si l'installation se produit sur un système de fichiers monté à/mnt, alors le magasin sera créé à/mnt/. npm-store. The same goes for Windows systems.

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

modules-dir

  • Default:node_modules
  • Type:chemin

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

node-linker

  • 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 as your linker.

symlink

  • Par défaut:true
  • Type:Boolean

Whensymlink is set tofalse, pnpm creates a virtual store directory without any symlinks. It is a useful setting together withnode-linker=pnp.

enable-modules-dir

  • Par défaut: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 with filesystem in userspace (FUSE). There is an experimental CLI that allows you to mount a modules directory with FUSE:@pnpm/mount-modules.

virtual-store-dir

  • Default:node_modules/.pnpm
  • Types:path

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

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

Ou vous pouvez définir la boutique virtuelle à.pnpm et l'ajouter à.gitignore. Ce rendra la pile plus propre car les chemins vers les dépendances seront un répertoire plus élevé.

NOTE: la boutique virtuelle ne peut pas être partagée entre plusieurs projets. Chaque projet devrait avoir sa propre boutique virtuelle (sauf dans les espaces de travail où la racine est partagée).

package-import-method

  • 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 thenode-linker setting, not this one).

  • auto - essayez de cloner des paquets de la boutique. Si le clonage n'est pas pris en charge alors les paquets hardlink du magasin. Si ni le clonage ni le lien ne sont possibles, retournez à la copie
  • 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.

modules-cache-max-age

  • 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 when switching branches or downgrading dependencies.

Lockfile Settings

lockfile

  • Par défaut:true
  • Type:Boolean

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

prefer-frozen-lockfile

  • Par défaut:true
  • Type:Boolean

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

lockfile-include-tarball-url

  • Par défaut:false
  • Type:Boolean

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

git-branch-lockfile

  • Par défaut:false
  • Type:Boolean

When set totrue, 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 isfeature-foo, the corresponding lockfile name will bepnpm-lock.feature-foo.yaml instead ofpnpm-lock.yaml. It is typically used in conjunction with the command line argument--merge-git-branch-lockfiles or by settingmerge-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.

Par exemple :

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

You may also exclude patterns using!.

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. For example, setting@babel:registry=https://example.com/packages/npm/ will enforce that when you usepnpm add @babel/core, or any@babel scoped package, the package will be fetched fromhttps://example.com/packages/npm instead of the default registry.

<URL>:_authToken

Define the authentication bearer token to use when accessing the specified registry. Par exemple:

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

You may also use an environment variable. Par exemple:

//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)"). Par exemple:

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 thestrict-ssl config.

cafile

  • Default:null
  • Type:chemin

A path to a file containing one or multiple Certificate Authority signing certificates. Similar to theca 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)"). Par exemple:

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

It is not the path to a certificate file (and there is nocertfile 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)"). Par exemple:

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.

git-shallow-hosts

  • Default:['github.com', 'gist.github.com', 'gitlab.com', 'bitbucket.com', 'bitbucket.org']
  • Type:boolean

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 be used instead.

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

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_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
  • 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

  • Par défaut:true
  • Type:Boolean

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

See also theca option.

network-concurrency

  • Default:16
  • Type:Number

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

fetch-retries

  • Default:2
  • Type:Number

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

fetch-retry-factor

  • Default:10
  • Type:Number

The exponential factor for retry backoff.

fetch-retry-mintimeout

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

The minimum (base) timeout for retrying requests.

fetch-retry-maxtimeout

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

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

fetch-timeout

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

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

Peer Dependency Settings

auto-install-peers

  • Par défaut: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.

dedupe-peer-dependents

  • Par défaut: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 thededupe-peer-dependents setting to deduplicatewebpack when it has no conflicting peer dependencies (explanation at the end). In this case, if we setdedupe-peer-dependents 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.

strict-peer-dependencies

  • Par défaut:false
  • Type: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

  • Par défaut: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.

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 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

  • Par défaut:false
  • Type: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

  • Par défaut: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 or subdirectory packages.

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

engine-strict

  • Par défaut:false
  • Type: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 itsengines field.

npm-path

  • Type:chemin

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

Build Settings

ignore-scripts

  • Par défaut:false
  • Type:Boolean

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

note

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

ignore-dep-scripts

  • Par défaut:false
  • Type:Boolean

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

child-concurrency

  • Default:5
  • Type:Number

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

side-effects-cache

  • Par défaut:true
  • Type:Boolean

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

side-effects-cache-readonly

  • Par défaut:false
  • Type:Boolean

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

unsafe-perm

  • 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.

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

This may be used instead of.nvmrc andnvm. 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 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, usenode-version andengine-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 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/

Workspace Settings

link-workspace-packages

  • Par défaut:true
  • Type:true,false,deep

If this is enabled, locally available packages are linked tonode_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 thedeep setting.

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

prefer-workspace-packages

  • Par défaut:false
  • Type: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 usesave-workspace-protocol.

shared-workspace-lockfile

  • Par défaut:true
  • Type:Boolean

If this is enabled, pnpm creates a singlepnpm-lock.yaml file in the root of the workspace. This also means that all dependencies of workspace packages will be in a singlenode_modules (and get symlinked to their packagenode_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 rootnode_modules, packages will have access only to those dependencies that are declared in theirpackage.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 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. Thesave-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

  • Par défaut:false
  • Type: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

  • Par défaut:false
  • Type:Boolean

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

disallow-workspace-cycles

Added in: v8.9.0

  • Par défaut:false
  • Type:Boolean

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

Other Settings

use-running-store-server

  • Par défaut:false
  • Type: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 apackage.json file get prefixed.

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 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 offoo inpackage.json to2, regardless of the value ofsave-prefix.

tag

  • Default:latest
  • Type:String

If youpnpm 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 thepackage@version specified by thepnpm tag command if no explicit tag is given.

global-dir

  • Par défaut:
    • 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:chemin

Specify a custom directory to store global packages.

global-bin-dir

  • Par défaut:
    • 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:chemin

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

state-dir

  • Par défaut:
    • 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:chemin

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

cache-dir

  • Par défaut:
    • 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:chemin

The location of the package metadata cache.

use-stderr

  • Par défaut:false
  • Type:Boolean

When true, all the output is written to stderr.

update-notifier

  • Par défaut:true
  • Type:Boolean

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

prefer-symlinked-executables

  • 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.

verify-store-integrity

  • Par défaut: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. Ifverify-store-integrity is set tofalse, files in the content-addressable store will not be checked during installation.

ignore-compatibility-db

  • Par défaut: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.

resolution-mode

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

Whenresolution-mode 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 theregistry-supports-time-field setting totrue, and it will be really fast.

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

registry-supports-time-field

  • Par défaut: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.

extend-node-path

  • Par défaut:true
  • Type:Boolean

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

deploy-all-files

  • Par défaut: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.

dedupe-direct-deps

Added in: v8.1.0

  • Par défaut: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.

dedupe-injected-deps

Added in: v8.13.1

  • Par défaut:false
  • 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.


[8]ページ先頭

©2009-2025 Movatter.jp