Passa al contenuto principale
Versione: 8.x

.npmrc

pnpm ottiene la sua configurazione da linea di comando, variabili d'ambiente e file .npmrc.

Il comando pnpm config può essere usato per aggiornare e modificare il contenuto del file .npmrc utente e globale.

I quattro file rilevanti sono:

  • file di configurazione per progetto (/percorso/del/mio/progetto/.npmrc)
  • file di configurazione per area di lavoro (la directory che contiene il file pnpm-workspace.yaml)
  • file di configurazione per utente (~/.npmrc)
  • file di configurazione globale (/etc/npmrc)

Tutti i file .npmrc sono un elenco in formato INI di parametri chiave = valore.

Impostazioni di inserimento delle dipendenze

hoist

  • Predefinito: true
  • Tipo: booleano

Quando true, tutte le dipendenze vengono installate in node_modules/.pnpm. Questo rende le dipendenze non elencate accessibili a tutti i pacchetti all'interno di node_modules.

hoist-pattern

  • Predefinito: ['*']
  • Tipo: stringa[]

Indica a pnpm quali pacchetti devono essere installati in node_modules/.pnpm. Per impostazione predefinita, tutti i pacchetti sono installati - tuttavia, se sai che solo alcuni pacchetti difettosi hanno dipendenze fantasma, è possibile utilizzare questa opzione per installare esclusivamente le dipendenze fantasma (raccomandato).

Ad esempio:

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

You may also exclude patterns from hoisting using !.

Ad esempio:

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

public-hoist-pattern

  • Predefinito: ['*eslint*', '*prettier*']
  • Tipo: stringa[]

A differenza di hoist-pattern, che installa le dipendenze in una cartella dei moduli nascosti all'interno dell'archivio virtuale, public-hoist-pattern installa le dipendenze che corrispondono al modello nella cartella dei moduli radice. Installare nella cartella radice dei moduli significa che il codice dell'applicazione avrà accesso alle dipendenze fantasma, anche se modificano la strategia di risoluzione in modo improprio.

Questa impostazione è utile quando si ha a che fare con alcuni strumenti collegabili difettosi che non risolvere correttamente le dipendenze.

Ad esempio:

public-hoist-pattern[]=*plugin*

Nota: Impostare shamefully-hoist a true è lo stesso dell'impostazione public-hoist-pattern a *.

You may also exclude patterns from hoisting using !.

Ad esempio:

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

shamefully-hoist

  • Predefinito: false
  • Tipo: Booleano

Per impostazione predefinita, pnpm crea un node_modules semi-rigoroso, il che significa che le dipendenze hanno accesso alle dipendenze non dichiarate ma i moduli al di fuori di node_modules no. Con questo layout, la maggior parte dei pacchetti nell'ecosistema funzionano senza problemi. Tuttavia, se alcuni strumenti funzionano solo quando le dipendenze installate si trovano nella radice di node_modules, puoi impostarlo su true in modo da installarle per te.

Impostazioni Node-Modules

store-dir

  • Predefinito:
    • 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
  • Tipo: percorso

La posizione in cui tutti i pacchetti vengono salvati sul disco.

L'archivio dovrebbe essere sempre sullo stesso disco su cui sta avvenendo l'installazione, quindi ci sarà un archivio per disco. Se è presente una directory home sul disco corrente, l'archivio viene creato al suo interno. Se non c'è nessuna home sul disco, allora l'archivio viene creato alla radice del filesystem. Ad esempio, se l'installazione avviene su un file system montato a /mnt, allora l'archivio viene creato in /mnt/.pnpm-store. Lo stesso vale per i sistemi Windows.

È possibile impostare un archivio da un disco diverso, ma in tal caso pnpm copierà i pacchetti dallo store invece di collegarli, poiché i collegamenti fisici sono possibili solo sullo stesso filesystem.

modules-dir

  • Predefinito: node_modules
  • Tipo: percorso

La cartella in cui verranno installate le dipendenze (invece di node_modules).

node-linker

  • Predefinito: isolated
  • Tipo: isolated, hoisted, pnp

Definisce quale linker dovrebbe essere usato per installare i pacchetti Node.

  • isolato - le dipendenze sono collegate simbolicamente da un negozio virtuale a node_modules/.pnpm.
  • hoisted - viene creata una node_modules piatta senza collegamenti simbolici. Uguale a node_modules creato da npm o Yarn Classic. Una delle librerie di Yarn viene utilizzata per l'hoisting, quando viene utilizzata questa impostazione. Motivi legittimi per utilizzare questa impostazione:
    1. I tuoi strumenti non funzionano bene con i collegamenti simbolici. Un progetto React Native molto probabilmente funzionerà solo se utilizzi una node_modules issata (hoisted).
    2. Il tuo progetto viene distribuito a un provider di hosting senza server. Alcuni provider senza server (ad esempio, AWS Lambda) non supportano i collegamenti simbolici. Una soluzione alternativa a questo problema consiste nel raggruppare l'applicazione prima della distribuzione.
    3. Se vuoi pubblicare il tuo pacchetto con "bundledDependencies".
    4. Se stai eseguendo Node.js con l'opzione --preserve-symlinks.
  • pnp - nessuna cartella node_modules. Plug'n'Play è una strategia innovativa per Node che è utilizzata da Yarn Berry. Si consiglia inoltre di impostare symlink su false quando si utilizza pnp come linker.
  • Predefinito: true
  • Tipo: Booleano

Quando symlink è impostato su false, pnpm crea una cartella dell'archivio virtuale senza alcun collegamento simbolico. È un'impostazione utile insieme a node-linker=pnp.

enable-modules-dir

  • Predefinito: true
  • Tipo: Booleano

Quando false, pnpm non scriverà alcun file nella cartella dei moduli (node_modules). Questo è utile quando la cartella dei moduli è montata con filesystem nello spazio utente (FUSE). Esiste una CLI sperimentale che consente di montare una cartella dei moduli con FUSE: @pnpm/mount-modules.

virtual-store-dir

  • Predefinito: node_modules/.pnpm
  • Tipi: percorso

La cartella con i collegamenti all'archivio. Tutte le dipendenze dirette e indirette del progetto sono collegate in questa cartella.

Questa è un'impostazione utile che può risolvere problemi con percorsi lunghi su Windows. Se hai alcune dipendenze con percorsi molto lunghi, puoi selezionare un archivio virtuale nella radice del tuo disco (ad esempio C:\my-project-store).

Oppure puoi impostare l'archivio virtuale su .pnpm e aggiungerlo a .gitignore. Questo renderà gli stacktrace più puliti poiché i percorsi delle dipendenze saranno di una cartella più in alto.

NOTA: l'archivio virtuale non può essere condiviso tra più progetti. Ogni progetto dovrebbe avere un proprio archivio virtuale (tranne negli spazi di lavoro dove è condivisa la radice).

package-import-method

  • Predefinito: null
  • Tipo: auto, hardlink, copy, clone, clone-or copy

Controlla il modo in cui i pacchetti vengono importati dall'archivio (se si desidera disabilitare i collegamenti simbolici all'interno di node_modules, è necessario modificare l'impostazione del node-linker, non questa).

  • auto - prova a clonare i pacchetti dall'archivio. Se la clonazione non è supportata collega i pacchetti dall'archivio. Se né la clonazione né il collegamento è possibile, esegue la copia
  • hardlink - collega fisicamente i pacchetti dall'archivio
  • clone-or-copy: prova a clonare i pacchetti dal negozio. Se la clonazione non è supportata, allora torna alla copia
  • copy - copia i pacchetti dall'archivio
  • clone - clona (alias copy-on-write o link di riferimento) i pacchetti dall'archivio

La clonazione è il modo migliore per scrivere pacchetti in node_modules. È il modo più veloce e più sicuro. Quando viene utilizzata la clonazione, puoi modificare i file nei tuoi node_modules e non verranno modificati nell'archivio centrale indirizzabile al contenuto.

Sfortunatamente, non tutti i file system supportano la clonazione. Si consiglia di utilizzare un file system copy-on-write (CoW) (ad esempio, Btrfs invece di Ext4 su Linux) per la migliore esperienza con pnpm.

info

Anche se macOS supporta la clonazione, al momento c'è un bug in Node.js che ci impedisce di usarlo in pnpm. Se hai idee su come risolverlo, aiutaci.

modules-cache-max-age

  • Predefinito: 10080 (7 giorni in minuti)
  • Tipo: numero

Il tempo in minuti dopo il quale i pacchetti orfani dalla cartella dei moduli devono essere rimossi. pnpm mantiene una cache dei pacchetti nella cartella dei moduli. Questa velocità di installazione aumenta quando si cambia ramo o si retrocedono delle dipendenze.

Impostazioni file di blocco

lockfile

  • Predefinito: true
  • Tipo: Booleano

Se impostato su false, pnpm non leggerà né genererà un file pnpm-lock.yaml.

prefer-frozen-lockfile

  • Predefinito: true
  • Tipo: Booleano

Quando è impostato su true e il pnpm-lock.yaml disponibile soddisfa il package.json, viene eseguita un'installazione headless. Un'installazione headless salta la risoluzione di tutte le dipendenze in quanto non ha bisogno per modificare il file di blocco.

lockfile-include-tarball-url

  • Predefinito: false
  • Tipo: Booleano

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

Impostazioni di autenticazione e del registro di sistema

registry

L'URL di base del registro del pacchetto npm (barra finale inclusa).

<scope>:registry

Il registro npm da utilizzare per i pacchetti dell'ambito specificato. Per esempio, impostando @babel:registry=https://esempio.com/packages/npm/ farà rispettare che quando usi pnpm add @babel/core, o qualsiasi pacchetto @babel con ambito, il pacchetto verrà recuperato da https://esempio.com/packages/npm invece del registro predefinito.

<URL>:_authToken

Definisci il token del portatore di autenticazione da utilizzare quando si accede al registro. Ad esempio:

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

Puoi anche usare una variabile d'ambiente. Ad esempio:

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

Un token helper è un eseguibile che emette un token di autenticazione. Può essere usato in situazioni in cui authToken non è un valore costante ma è qualcosa che si aggiorna regolarmente, in cui uno script o un altro strumento può usare un token di aggiornamento esistente per ottenere un nuovo token di accesso.

La configurazione per il percorso dell'helper deve essere un percorso assoluto, senza argomenti. Per essere sicuro, è consentito impostare questo valore solo nell'utente .npmrc. In caso contrario, un progetto potrebbe inserire un valore in .npmrc locale di un progetto ed eseguire eseguibili arbitrari.

Impostazione di un token helper per il registro predefinito:

tokenHelper=/home/ivan/token-generator

Impostazione di un token helper per il registro specificato:

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

Impostazioni richiesta

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)"). Ad esempio:

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

  • Predefinito: null
  • Tipo: percorso

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

  • Predefinito: null
  • Tipo: Stringa

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

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

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

key

  • Predefinito: null
  • Tipo: Stringa

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

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']
  • Tipo: stringa[]

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

  • Predefinito: null
  • Type: 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. Ad esempio:

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

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

http-proxy

proxy

  • Predefinito: 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
  • Tipo: Numero

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

noproxy

  • Predefinito: null
  • Tipo: Stringa

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

strict-ssl

  • Predefinito: true
  • Tipo: Booleano

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
  • Tipo: Numero

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

fetch-retries

  • Default: 2
  • Tipo: Numero

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

fetch-retry-factor

  • Default: 10
  • Tipo: Numero

The exponential factor for retry backoff.

fetch-retry-mintimeout

  • Default: 10000 (10 seconds)
  • Tipo: Numero

The minimum (base) timeout for retrying requests.

fetch-retry-maxtimeout

  • Predefinito: 60000 (1 minuto)
  • Tipo: Numero

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

fetch-timeout

  • Predefinito: 60000 (1 minuto)
  • Tipo: Numero

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

Impostazioni dipendenze peer

auto-install-peers

  • Predefinito: true
  • Tipo: Booleano

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

dedupe-peer-dependents

  • Predefinito: true
  • Tipo: Booleano

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

  • Predefinito: false
  • Tipo: Booleano

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

resolve-peers-from-workspace-root

  • Predefinito: true
  • Tipo: Booleano

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.

Impostazioni CLI

[no-]color

  • Predefinito: null
  • 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

  • Predefinito: false
  • Tipo: Booleano

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

  • Predefinito: true
  • Tipo: Booleano

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

  • Predefinito: false
  • Tipo: Booleano

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

  • Tipo: percorso

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

Impostazioni di compilazione

ignore-scripts

  • Predefinito: false
  • Tipo: Booleano

Non eseguire alcun script definito nel file package.json del progetto e nelle sue dipendenze.

note

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

ignore-dep-scripts

  • Predefinito: false
  • Tipo: Booleano

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

child-concurrency

  • Default: 5
  • Tipo: Numero

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

side-effects-cache

  • Predefinito: true
  • Tipo: Booleano

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

side-effects-cache-readonly

  • Predefinito: false
  • Tipo: Booleano

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
  • Tipo: Booleano

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.

Impostazioni di Node.js

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/

Impostazioni dell'area di lavoro

  • Predefinito: 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

  • Predefinito: false
  • Tipo: Booleano

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

  • Predefinito: true
  • Tipo: Booleano

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

  • Predefinito: false
  • Tipo: Booleano

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

ignore-worksapce-cycles

Added in: v8.1.0

  • Predefinito: false
  • Tipo: Booleano

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

Altre opzioni

use-running-store-server

  • Predefinito: false
  • Tipo: Booleano

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

save-prefix

  • Default: '^'
  • Tipo: Stringa

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
  • Tipo: Stringa

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

  • Predefinito:
    • 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
  • Tipo: percorso

Specify a custom directory to store global packages.

global-bin-dir

  • Predefinito:
    • 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
  • Tipo: percorso

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

state-dir

  • Predefinito:
    • 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
  • Tipo: percorso

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

cache-dir

  • Predefinito:
    • 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
  • Tipo: percorso

The location of the package metadata cache.

use-stderr

  • Predefinito: false
  • Tipo: Booleano

When true, all the output is written to stderr.

update-notifier

  • Predefinito: true
  • Tipo: Booleano

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
  • Tipo: Booleano

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

  • Predefinito: true
  • Tipo: Booleano

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

  • Predefinito: false
  • Tipo: Booleano

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: lowest-direct
  • Type: highest, time-based, lowest-direct

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

  1. Le dipendenze dirette verranno risolte alle versioni più basse. Quindi se c'è foo@^1.1.0 nelle dipendenze, verrà installato 1.1.0.
  2. Le sottodipendenze verranno risolte dalle versioni pubblicate prima della pubblicazione dell'ultima dipendenza diretta.

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

  • Predefinito: false
  • Tipo: Booleano

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

  • Predefinito: true
  • Tipo: Booleano

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

deploy-all-files

  • Predefinito: false
  • Tipo: Booleano

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

Added in: v8.1.0

  • Predefinito: false
  • Tipo: Booleano

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.