Movatterモバイル変換


[0]ホーム

URL:


Saltar al contenido principal
Version: 10.x

Settings (.npmrc)

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

Thepnpm config command can be used to update and edit the contents of theuser and global.npmrc files.

Los cuatro archivos relevantes son:

  • per-project configuration file (/path/to/my/project/.npmrc)
  • per-workspace configuration file (the directory that contains thepnpm-workspace.yaml file)
  • per-user configuration file (~/.npmrc)
  • global configuration file (/etc/npmrc)

All.npmrc files are anINI-formatted list ofkey = value parameters.

Values in the.npmrc files may contain env variables using the${NAME} syntax. Las variables env también se pueden especificar con valores predeterminados. Using${NAME-fallback} will returnfallback ifNAME isn't set.${NAME:-fallback} will returnfallback ifNAME isn't set, or is an empty string.

Configuración de elevación de dependencia

hoist

  • Default:true
  • Type:boolean

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

hoist-workspace-packages

  • 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 (hoist-pattern andpublic-hoist-pattern).

hoist-pattern

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

Tells pnpm which packages should be hoisted tonode_modules/.pnpm/node_modules. De predeterminada, todos los paquetes se elevan; sin embargo, si sabe que solo algunos paquetes tienen dependencias fantasmas, puede usar esta opción para elevarlas dependencias fantasmas (recomendado).

Por ejemplo:

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

You may also exclude patterns from hoisting using!.

Por ejemplo:

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

public-hoist-pattern

  • Default:[]
  • Type:string[]

Unlikehoist-pattern, which hoists dependencies to a hidden modules directoryinside the virtual store,public-hoist-pattern hoists dependencies matchingthe pattern to the root modules directory. Elevar al directorio de módulos raízsignifica que el código de la aplicación tendrá acceso a las dependencias fantasma,incluso si modifican la estrategia de resolución de manera incorrecta.

Esta configuración es útil cuando se trata de algunas herramientas conectables defectuosas queresuelven las dependencias correctamente.

Por ejemplo:

public-hoist-pattern[]=*plugin*

Note: Settingshamefully-hoist totrue is the same as settingpublic-hoist-pattern to*.

You may also exclude patterns from hoisting using!.

Por ejemplo:

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

shamefully-hoist

  • Default:false
  • Type:Boolean

By default, pnpm creates a semistrictnode_modules, meaning dependencies haveaccess to undeclared dependencies but modules outside ofnode_modules do not.Con este diseño, la mayoría de los paquetes del ecosistema funcionan sin problemas.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.

Configuración de Node-Modules

modules-dir

  • Default:node_modules
  • Type:path

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

node-linker

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

Define qué enlazador debe usarse para instalar paquetes de Node.

  • 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. Una de las bibliotecas de Yarn se usa para elevar, cuando se usa esta configuración. Razones legítimas para usar esta configuración:
    1. Su herramienta no funciona bien con enlaces simbólicos. A React Native project will most probably only work if you use a hoistednode_modules.
    2. Su proyecto se implementa en un proveedor de alojamiento sin servidor. Algunos proveedores sin servidor (por ejemplo, AWS Lambda) no admiten enlaces simbólicos. Una solución alternativa para este problema es empaquetar la aplicación antes del despliegue.
    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 withnode-linker=pnp.

enable-modules-dir

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

virtual-store-dir

  • Default:node_modules/.pnpm
  • Types:path

El directorio con enlaces a la tienda. Todas las dependencias directas e indirectas delproyecto están vinculadas a este directorio.

Esta es una configuración útil que puede resolver problemas con rutas largas en 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. Estehará que los seguimientos de pila sean más limpios, ya que las rutas a las dependencias estarán un directoriomás arriba.

NOTE: the virtual store cannot be shared between several projects. Cada proyectodebe tener su propio alamcenamiento virtual (excepto en los espacios de trabajo donde se comparte la raíz).

virtual-store-dir-max-length

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

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 - try to clone packages from the store. Si no se admite la clonaciónentonces vincula los paquetes del almacenamiento. Si ni la clonación ni la vinculación sonposibles, vuelva a copiar
  • hardlink - hard link packages from the store
  • clone-or-copy - try to clone packages from the store. Si no se admite la clonación, vuelva a copiar
  • copy - copy packages from the store
  • clone - clone (AKA copy-on-write or reference link) packages from the store

La clonación es la mejor manera de escribir paquetes en node_modules. Es la forma más rápida y segura. Cuando se usa la clonación, puede editar archivos en sus node_modules y no se modificarán en el almacenamiento central de contenido direccionable.

Desafortunadamente, no todos los sistemas de archivos admiten la clonación. Recomendamos utilizar un sistema de archivos de copia en escritura (CoW) (por ejemplo, Btrfs en lugar de Ext4 en Linux) para obtener la mejor experiencia con pnpm.

modules-cache-max-age

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

El tiempo en minutos después del cual se deben eliminar los paquetes huérfanos del directorio de módulos.pnpm mantiene un caché de paquetes en el directorio de módulos. Esto aumenta la velocidad de instalación al cambiar deo degradar dependencias.

dlx-cache-max-age

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

Store Settings

store-dir

  • Por defecto
    • 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

La ubicación donde se guardan todos los paquetes en el disco.

El almacenamiento debe estar siempre en el mismo disco en el que se realiza la instalación,Así que habrá un almacenamiento por disco. Si hay un directorio de inicio en el discoactual, el almacenamiento se crea dentro de él. Si no hay un hogar en el disco,, entonces el almacenamiento se crea en la raíz del sistema de archivos. Forexample, if installation is happening on a filesystem mounted at/mnt,then the store will be created at/mnt/.pnpm-store. Lo mismo ocurre con los sistemas Windows.

Es posible configurar un almacenamiento desde un disco diferente, pero en ese caso, pnpmcopiará los paquetes del almacenamiento en lugar de vincularlos, ya que los enlaces físicosson posibles en el mismo sistema de archivos.

verify-store-integrity

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

use-running-store-server

danger

Deprecated feature

  • Default:false
  • Type:Boolean

Solo permite la instalación con un servidor de almacenamiento. Si no se está ejecutando ningún servidor de almacenamiento,instalación fallará.

strict-store-pkg-content-check

  • 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 thestrict-store-pkg-content-check setting tofalse.

Configuración de Lockfile

lockfile

  • Default:true
  • Type:Boolean

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

prefer-frozen-lockfile

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

lockfile-include-tarball-url

  • Default:false
  • Type:Boolean

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

git-branch-lockfile

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

Por ejemplo:

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

You may also exclude patterns using!.

peers-suffix-max-length

  • 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. Por ejemplo:

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

You may also use an environment variable. Por ejemplo:

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

Ajustes de Solicitud

ca

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

El certificado de firma de la autoridad de certificación en el que se confía para las conexiones SSLcon el registro. Los valores deben estar en formato PEM (también conocido como"X.509 codificado en Base-64 (.CER)"). Por ejemplo:

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

Se establece en nulo para permitir sólo a los registradores conocidos, o a un certificado de CA específico para confiar ensólo la autorización de firma específica.

Se puede confiar en varias CA especificando una arreglo de certificados:

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

See also thestrict-ssl config.

cafile

  • Default:null
  • Type:path

Una ruta a un archivo que contiene uno o varios certificados de firma de autoridad de certificación. 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. Por ejemplo:

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

cert

  • Default:null
  • Type:String

Un certificado de cliente para pasar al acceder al registro. Los valores deben estar en formato PEM (también conocido como"X.509 codificado en Base-64 (.CER)"). Por ejemplo:

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. Por ejemplo:

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

key

  • Default:null
  • Type:String

Una clave de cliente para pasar al acceder al registro. Los valores deben estar en formato PEM (también conocido como"X.509 codificado en Base-64 (.CER)"). Por ejemplo:

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

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

Esta configuración contiene información confidencial. 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. Por ejemplo:

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

git-shallow-hosts

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

Al obtener dependencias que son repositorios de Git, si el host aparece en esta configuración, pnpm usará una clonación superficial para obtener solo la confirmación necesaria, no todo el historial.

https-proxy

  • Default:null
  • Type:url

Un proxy para usar con solicitudes HTTPS salientes. 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.Por ejemplo:

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

Un proxy para usar con solicitudes http salientes. Si se establecen las variables de entorno HTTP_PROXY o http_proxy, la biblioteca de solicitudsubyacente respetará la configuración del proxy.

local-address

  • Default:undefined
  • Type:IP Address

La dirección IP de la interfaz local que se usará al realizar conexiones con el registro npm.

maxsockets

  • Default:network-concurrency x 3
  • Type:Number

El número máximo de conexiones a usar por origen (combinación de protocolo/host/puerto).

noproxy

  • Default:null
  • Type:String

Una cadena de extensiones de dominio separadas por comas para las que no se debe usar un proxy.

strict-ssl

  • Default:true
  • Type:Boolean

Si realizar o no la validación de la clave SSL al realizar solicitudes al registro a través deHTTPS.

See also theca option.

network-concurrency

  • Default:16
  • Type:Number

Controla el número máximo de solicitudes HTTP(S) para procesar simultáneamente.

fetch-retries

  • Default:2
  • Type:Number

Cuántas veces se debe volver a intentar si pnpm no se obtiene del registro.

fetch-retry-factor

  • Default:10
  • Type:Number

El factor exponencial para el retroceso de reintento.

fetch-retry-mintimeout

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

El tiempo de espera mínimo (base) para reintentar solicitudes.

fetch-retry-maxtimeout

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

El tiempo de espera de reserva máximo para garantizar que el factor de reintento no haga que las solicitudessean demasiado largas.

fetch-timeout

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

La cantidad máxima de tiempo de espera para que se completen las solicitudes HTTP.

Peer Dependency Settings

auto-install-peers

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

dedupe-peer-dependents

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

  • Default:false
  • Type:Boolean

Si está habilitado, los comandos fallarán si falta una dependencia del paro no es válida en el árbol.

resolve-peers-from-workspace-root

  • Default:true
  • Type:Boolean

Cuando está habilitado, las dependencias del proyecto del espacio de trabajo raíz se utilizan para resolver las dependencias de pares de cualquier proyecto en el espacio de trabajo.Es una característica útil, ya que puede instalar las dependencias del mismo nivel solo en la raíz del área de trabajo y puede estar seguro de que todos los proyectos del área de trabajo utilizan las mismas versiones de las dependencias del mismo nivel.

Configuración de CLI

[no-]color

  • Default:auto
  • Type:auto,always,never

Controla los colores en la salida.

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

use-beta-cli

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

recursive-install

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

engine-strict

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

npm-path

  • Type:path

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

package-manager-strict

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

package-manager-strict-version

  • Default:false
  • Type:Boolean

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

manage-package-manager-versions

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

{
"packageManager":"pnpm@9.3.0"
}

Configuración de compilación

ignore-scripts

  • 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

ignore-dep-scripts

  • 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 in thepnpm.onlyBuiltDependencies field ofpackage.json.

child-concurrency

  • Default:5
  • Type:Number

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

side-effects-cache

  • Default:true
  • Type:Boolean

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

side-effects-cache-readonly

  • Default: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-options

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

verify-deps-before-run

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

strict-dep-builds

Added in: v10.3.0

  • Default:false
  • Type:Boolean

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

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 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 this.npmrc file:

use-node-version=16.16.0

This setting works only in a.npmrc 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 thepnpm.executionEnv.nodeVersion field ofpackage.json instead.

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

De esta manera, incluso si alguien usa Node.js v16, no podrá instalar una nueva dependencia que no admita Node.js v12.22.0.

node-mirror:<releaseDir>

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

Establece la URL base para descargar Node.js. The<releaseDir> portion of this setting can be any directory fromhttps://nodejs.org/download:release,rc,nightly,v8-canary, etc.

Así es como se puede configurar pnpm para descargar Node.js desde el espejo de Node.js en 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/

Configuración del espacio de trabajo

link-workspace-packages

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

inject-workspace-packages

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

sync-injected-deps-after-scripts

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.

prefer-workspace-packages

  • 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 usesave-workspace-protocol.

shared-workspace-lockfile

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

  • cada dependencia es un singleton
  • instalaciones más rápidas en un monorepo
  • menos cambios en las revisiones de código, ya que están todos en un solo archivo
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.

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

  • Default:false
  • Type:Boolean

Al ejecutar comandos recursivamente en un espacio de trabajo, ejecútelos también en el proyecto del espacio de trabajo raíz.

ignore-workspace-cycles

  • Default:false
  • Type:Boolean

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

disallow-workspace-cycles

  • Default:false
  • Type:Boolean

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

Deploy Settings

force-legacy-deploy

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

Otros ajustes

save-prefix

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

Esta configuración se ignora cuando el paquete agregado tiene un rango especificado. Forinstance,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 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.

global-dir

  • Por defecto
    • 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

Especifique un directorio personalizado para almacenar paquetes globales.

global-bin-dir

  • Por defecto
    • 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

Permite establecer el directorio de destino para los archivos bin de los paquetes instalados globalmente.

state-dir

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

cache-dir

  • Por defecto
    • 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).

use-stderr

  • Default:false
  • Type:Boolean

Cuando es verdadero, toda la salida se escribe en stderr.

update-notifier

  • Default: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. Esta configuración se ignora en Windows, donde solo funcionan las correcciones de compatibilidad de comandos.

ignore-compatibility-db

  • Default:false
  • Type:Boolean

Durante la instalación, las dependencias de algunos paquetes se parchean automáticamente. 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. Las dependencias directas se resolverán a sus versiones más bajas. So if there isfoo@^1.1.0 in the dependencies, then1.1.0 will be installed.
  2. Las subdependencias se resolverán a partir de versiones que se publicaron antes de que se publicara la última dependencia directa.

Con este modo de resolución, las instalaciones con caché caliente son más rápidas. También reduce la posibilidad de secuestro de subdependencias, ya que las subdependencias se actualizarán solo si se actualizan las dependencias directas.

This resolution mode works only with npm'sfull metadata. Por lo tanto, es más lento en algunos escenarios. 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

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

extend-node-path

  • Default:true
  • Type:Boolean

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

deploy-all-files

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

dedupe-direct-deps

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

dedupe-injected-deps

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

optimistic-repeat-install

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.


[8]ページ先頭

©2009-2025 Movatter.jp