pnpm 中的 .npmrc 文件配置

简介: .npmrc 文件是一个使用 .ini 文件格式书写的配置文件。本文介绍pnpm 中的 .npmrc 文件配置方法。

pnpm 中的 .npmrc 文件配置


jcLee95 的个人博客

邮箱:291148484@163.com

本文地址
- https://developer.aliyun.com/article/
- https://blog.csdn.net/qq_28550263/article/details/128383429

介 绍


.npmrc 文件是一个使用 .ini 文件格式书写的配置文件。 pnpm 使用 .npmrc 文件配置以下几个方面内容:

附:


1.依赖性提升设置

hoist

如果为true,所有的依赖项都被提升到node_modules/.pnpm。这使得node_modules中的所有包都可以访问未列出的依赖项。

hoist=true,

public-hoist-pattern

告诉pnpm应该将哪些程序包提升到node_modules/.pnpm。默认情况下,所有程序包都会被提升——但是,如果您知道只有一些有缺陷的程序包具有幻影依赖项,则可以使用此选项专门提升幻影依赖项(推荐)。

hoist-pattern[]=eslint

hoist-pattern[]=babel

hoist-pattern=[‘*’]

与将依赖项提升到虚拟存储中的隐藏模块目录不同,公共提升模式将匹配模式的依赖项提升到根模块目录。提升到根模块目录意味着应用程序代码将可以访问幻象依赖,即使它们不正确地修改了解析策略。

Type: string[]

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

public-hoist-pattern=[‘eslint’, ‘prettier’]

shamefully-hoist

默认情况下,pnpm创建一个半严格的node_modules,这意味着依赖关系可以访问未声明的依赖关系,但是node_modules之外的模块则不能。

使用这种布局,生态系统中的大多数包都可以正常工作。

但是,如果某些工具仅在提升的依赖项位于node_modules的根中时才起作用,那么您可以将此设置为true来为您提升它们。

Type: Boolean

shamefully-hoist=false

2. Node模块设置

store-dir

磁盘上保存所有包的位置。

存储应该总是在进行安装的同一个磁盘上,所以每个磁盘上有一个存储。

如果当前磁盘上有一个主目录,那么将在其中创建存储。如果磁盘上没有主目录,那么就在文件系统的根目录下创建存储。

例如,如果安装发生在挂载在/mnt的文件系统上,那么将在/mnt/创建存储。pnpm-商店。Windows系统也是如此。

可以从不同的磁盘设置存储,但是在这种情况下,pnpm将从存储中复制包,而不是硬链接它们,因为硬链接只可能在同一个文件系统上。

store-dir=~/AppData/Local/pnpm/store

modules-dir

将安装依赖项的目录(而不是node_modules)。

modules-dir=node_modules

node-linker

定义应该使用什么链接器来安装Node包。

Type: isolated, hoisted, pnp

  • isolated - 依赖项从node_modules/.pnpm的虚拟存储进行符号链接。
  • hoisted - 创建了没有符号链接的平面node_modules。与npm或Yarn Classic创建的node_modules相同。
  • pnp - 没有节点模块。即插即用是一种创新的Node策略,纱线浆果使用。当使用pnp作为链接器时,建议将symlink设置也设置为false。

node-linker=isolated

symlink

当symlink设置为false时,pnpm创建一个没有任何符号链接的虚拟存储目录。与node-linker=pnp一起使用,这是一个非常有用的设置。

symlink=true

enable-modules-dir

如果为false,pnpm不会将任何文件写入模块目录(node_modules)。这对于在用户空间(FUSE)中使用文件系统挂载模块目录非常有用。

有一个实验性的CLI允许您用FUSE挂载一个模块目录:@pnpm/mount-modules。

enable-modules-dir=true

virtual-store-dir

带有商店链接的目录。项目的所有直接和间接依赖项都链接到这个目录中。

这是一个有用的设置,可以解决Windows上的长路径问题。

如果您有一些路径很长的依赖项,您可以在您的驱动器的根目录中选择一个虚拟存储(例如C:\my-project-store)。

注意:虚拟存储不能在几个项目之间共享。每个项目都应该有自己的虚拟存储(除了共享根的工作区)。v

virtual-store-dir=node_modules/.pnpm

package-import-method

控制从存储中导入包的方式(如果您想要禁用node_modules中的符号链接,那么您需要更改节点链接器设置,而不是这个设置)。

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

  • auto -尝试从存储克隆包。如果不支持克隆,那么从存储硬链接软件包。如果克隆和链接都不可行,就回到复制
  • hardlink - 从存储的硬链接包
  • clone-or-copy - 尝试从存储克隆包。如果不支持克隆,则退回到复制
  • copy - 从存储复制包
  • clone - 从存储克隆 (也叫做 copy-on-write 或 reference link) 包

package-import-method=auto

modules-cache-max-age

以分钟为单位的时间,在该时间之后,应该从模块目录中删除孤立包。pnpm在模块目录中保存了一个包缓存。

这在切换分支或降级依赖关系时提高了安装速度。

modules-cache-max-age=10080

3.Lockfile 文件设置

lockfile

当设置为false时,pnpm不会读取或生成pnpm-lock.yaml文件。

lockfile=true

prefer-frozen-lockfile

当设置为true并且可用的pnpm-lock.yaml满足package.json依赖项指令时,将执行无头安装。无头安装跳过所有依赖关系解析,因为它不需要修改锁定文件。

prefer-frozen-lockfile=true

lockfile-include-tarball-url

将包的tarball的完整URL添加到pnpm-lock.yaml中的每个条目。

lockfile-include-tarball-url=false

4.注册处和身份验证设置

registry

npm程序包注册表的基本URL(包括尾随斜杠)。

应该用于指定范围的程序包的npm注册表。

例如,设置 @babel:registry=https://example.com/packages/npm/ will enforce that when you use pnpm add @babel/core, or any @babel scoped package, the package will be fetched from https://example.com/packages/npm instead of the default registry.

registry=https://registry.npmjs.org/

5.请求设置

ca

证书颁发机构签署受信任的证书,用于与注册表的SSL连接。

值应该是PEM格式(也称为“Base-64编码X.509(.CER)”)。例如:

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

设置为null以仅允许已知的注册商,或者设置为特定的CA证书以仅信任该特定的签名机构。

通过指定一组证书,可以信任多个ca:

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

Type: String, Array or null

Default: npm CA证书

另请参见strict-ssl配置。

cafile

包含一个或多个证书颁发机构签名证书的文件的路径。

类似于ca设置,但允许多个CA,以及将CA信息存储在文件中,而不是通过CLI指定。

Default: null

cert

访问注册表时要传递的客户端证书。

值应该是PEM格式(也称为“Base-64编码X.509(.CER)”)。例如:

Default: null

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

它不是证书文件的路径(并且没有certfile选项)。

key

访问注册表时要传递的客户端密钥。

值应该是PEM格式(也称为“Base-64编码X.509(.CER)”)。例如:

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

它不是密钥文件的路径(也没有密钥文件选项)。

此设置包含敏感信息。不要写给当地人。npmrc文件已提交到存储库。

Default: null

git-shallow-hosts

当获取作为Git存储库的依赖项时,如果主机在此设置中列出,pnpm将使用浅层克隆来仅获取所需的提交,而不是所有的历史。

Type: string[]

git-shallow-hosts=[‘github.com’, ‘gist.github.com’, ‘gitlab.com’, ‘bitbucket.com’, ‘bitbucket.org’]

https-proxy

用于传出HTTPS请求的代理。如果设置了httpS代理、https代理、HTTP代理或HTTP代理环境变量,将使用它们的值。

Default: null

local-address

连接到npm注册表时使用的本地接口的IP地址。

Default: undefined

proxy

用于传出http请求的代理。如果设置了HTTP_PROXY或http_proxy环境变量,代理设置将被基础请求库接受。

Default: null

maxsockets

每个源使用的最大连接数(协议/主机/端口组合)。

Default: network-concurrency x 3

noproxy

不应使用代理的逗号分隔的域扩展名字符串。

Default: null

strict-ssl

通过HTTPS向注册中心发出请求时,是否进行SSL密钥验证。

Default: true

strict-ssl=true

控制同时处理的HTTP(S)请求的最大数量。

Default: 16

network-concurrency=16

fetch-retries

如果pnpm无法从注册表中获取数据,重试的次数。

Default: 2

fetch-retries=2

fetch-retry-factor

重试撤回的指数因子。

Default: 10

fetch-retry-factor=10

fetch-retry-mintimeout

重试请求的最小(基本)超时。

Default: 10000 (10 seconds)

fetch-retry-mintimeout=10000

fetch-retry-maxtimeout

确保重试因素不会使请求过长的最大回退超时。

Default: 60000 (1 minute)

fetch-retry-maxtimeout=60000

fetch-timeout

等待HTTP请求完成的最长时间。

Default: 60000 (1 minute)

fetch-timeout=60000

6. Peer Dependency 设置

auto-install-peers

如果为true,将自动安装任何缺少的非可选对等依赖项。

Default: false

auto-install-peers=false

strict-peer-dependencies

如果启用此选项,如果树中缺少对等依赖项或对等依赖项无效,命令将会失败。

Default: false (was true from v7.0.0 until v7.13.5)

strict-peer-dependencies=false

7. CLI 设置

color

控制输出中的颜色。

Default: auto

Type: auto, always, never

  • auto - 当标准输出是终端或TTY时,输出使用颜色。
  • always - 忽略端子和管道的区别。你很少会想要这个;在大多数情况下,如果您希望在重定向的输出中使用颜色代码,您可以向pnpm命令传递一个- color标志来强制它使用颜色代码。默认设置几乎总是您想要的。
  • never - 关闭颜色。这是- no-color使用的设置。

color=auto

loglevel

将显示任何等于或高于给定级别的日志。您可以改为传递- silent来关闭所有输出日志。

Default: info

Type: debug, info, warn, error

loglevel=info

use-beta-cli

启用CLI测试功能的实验选项。这意味着您可能会对CLI功能进行一些更改,这些更改是突破性的更改,或者是潜在的错误。

Default: false

use-beta-cli=false

recursive-install

如果启用此选项,pnpm install的主要行为将变成pnpm install -r的行为,这意味着安装将在所有工作区或子目录包中执行。

否则,pnpm install将在当前目录中专门构建软件包。

Default: true

recursive-install=true

engine-strict

如果启用此选项,pnpm将不会安装任何声称与当前节点版本不兼容的软件包。

不管这种配置如何,如果项目(不是依赖项)在其引擎字段中指定了不兼容的版本,安装将总是失败。

engine-strict=false

npm-path

pnpm用于某些操作(如发布)的npm二进制文件的位置。

8.构建设置

ignore-scripts

不要执行项目package.json及其依赖项中定义的任何脚本。

此标志不会阻止. pnpmfile.cjs的执行

ignore-scripts=false

ignore-dep-scripts

不要执行已安装软件包的任何脚本。执行项目的脚本。

Default: false

ignore-dep-scripts=false

child-concurrency

为构建node_modules而同时分配的子进程的最大数量。

Default: 5

child-concurrency=5

side-effects-cache

使用并缓存(预/后)安装挂钩的结果。

Default: true

side-effects-cache=true

side-effects-cache-readonly

仅使用副作用缓存(如果存在),不要为新包创建它。

Default: false

side-effects-cache-readonly=false

unsafe-perm

设置为true以在运行包脚本时启用UID/GID切换。如果明确设置为false,则以非root用户身份安装将会失败。

Default: false IF running as root, ELSE true

unsafe-perm=false

9.Node.js 设置

use-node-version

指定项目运行时应使用哪个确切的Node.js版本。

pnpm将自动安装指定版本的Node.js,并使用它来运行pnpm run命令或pnpm node命令。

这可以用来代替 .nvmrc 和 nvm。而不是下面的 .nvmrc 文件:

Type: semver

Default: undefined

use-node-version=19.2.0

node-version

如果您希望防止项目的参与者添加新的不兼容依赖项,请在项目根目录下的. npmrc文件中使用节点版本和引擎严格

Type: semver

Default: node -v返回的值,不带v前缀

node-version=19.2.0

node-mirror

设置下载Node.js的基本URL。

该设置的< releaseDir >部分可以是https://nodejs.org/download:版本、rc、nightly、v8-canary等中的任何目录。

node-mirror=https://nodejs.org/download/release/

10.工作区设置

link-workspace-packages

如果启用此选项,本地可用的包将链接到node_modules,而不是从注册表下载。这在monorepo中非常方便。如果您需要本地包也链接到子依赖项,您可以使用deep设置。

否则,从注册表下载并安装软件包。但是,仍然可以使用workspace: range协议链接工作空间包。

Type: true, false, deep

link-workspace-packages=true

prefer-workspace-packages

如果启用此选项,则工作区中的本地包优先于注册表中的包,即使注册表中有更新版本的包也是如此。

Default: false

prefer-workspace-packages=false

shared-workspace-lockfile

如果启用此选项,pnpm会在工作区的根目录下创建一个pnpm-lock.yaml文件。

这也意味着工作区包的所有依赖项都将位于单个node_modules中(并通过符号链接到它们的包node_modules文件夹,以便进行节点的模块解析)。

Default: true

shared-workspace-lockfile=true

save-workspace-protocol

此设置控制如何将从工作区链接的依赖项添加到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.

保存前缀设置也会影响等级库的创建方式。

Default: true

Type: true, false, rolling

https://pnpm.io/npmrc#save-workspace-protocol

save-workspace-protocol=true

include-workspace-root

当在工作空间中递归地执行命令时,也在根工作空间项目中执行它们。

Default: false

include-workspace-root=flase

11.其它设置

use-running-store-server

仅允许与存储服务器一起安装。如果没有存储服务器正在运行,安装将会失败。

use-running-store-server=false

save-prefix

配置安装到package.json文件的软件包版本如何获得前缀。

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.

当添加的包指定了范围时,此设置将被忽略。

For instance, pnpm add foo@2 will set the version of foo in package.json to 2, regardless of the value of save-prefix.

save-prefix=^

tag

如果您pnpm添加了一个包,但是您没有提供一个特定的版本,那么它将会在这个设置的标签下注册的版本上安装这个包。

如果没有给出明确的标记,这还会设置添加到由pnpm tag命令指定的package@version中的标记。

Default: latest

指定一个自定义目录来存储全局包。

tag=latest

global-dir

指定一个自定义目录来存储全局包。

global-dir=~/AppData/Local/pnpm/global

global-bin-dir

允许为全局安装的软件包的bin文件设置目标目录。

global-bin-dir=~/AppData/Local/pnpm

state-dir

pnpm创建pnpm-state.json文件的目录,该文件当前仅由更新检查器使用。

state-dir=~/AppData/Local/pnpm-state

cache-dir

包元数据缓存的位置。

cache-dir=~/AppData/Local/pnpm-cache

use-stderr

为真时,所有输出都写入stderr。

Default: false

use-stderr=false

update-notifier

如果设置为false,则在使用pnpm的旧版本而不是最新版本时,将禁止更新通知。

Default: true

update-notifier=true

prefer-symlinked-executables

在node_modules/中创建指向可执行文件的符号链接。绑定而不是命令垫片。

此设置在Windows上被忽略,在Windows上只有command shims起作用。

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

prefer-symlinked-executables=true

verify-store-integrity

默认情况下,如果存储区中的文件已经被修改,则在将该文件链接到项目的node_modules之前,会检查该文件的内容。

如果verify-store-integrity设置为false,则在安装过程中不会检查内容可寻址存储中的文件。

Default: true

verify-store-integrity=true

ignore-compatibility-db

在安装过程中,一些软件包的依赖项会被自动修补。如果您想禁用它,请将此配置设置为false。

这些补丁是从Yarn的@yarnpkg/extensions包中应用的。

Default: false

ignore-compatibility-db=false

resolution-mode

当解析模式设置为基于时间时,将通过以下方式解析相关性:

  • 直接依赖项将被解析为其最低版本。因此,如果依赖项中有foo@^1.1.0,那么将安装1.1.0。
  • 将从最后一个直接依赖项发布之前发布的版本中解析子依赖项。
    在这种分辨率模式下,使用热缓存的安装速度更快。
    它还减少了子依赖劫持的机会,因为只有当直接依赖被更新时,子依赖才会被更新。
    此解析模式仅适用于npm的完整元数据。
    所以在某些情况下会慢一些。但是,如果您使用Verdaccio v5.15.1或更高版本,您可以将registry-supports-time-field设置为true,这样会非常快。
    Type: highest, time-based
    Default: highest
    resolution-mode=highest

registry-supports-time-field

如果您使用的注册表返回缩写元数据中的“time”字段,请将此项设置为true。

截至目前,只有v5.15.1版本的Verdaccio支持此功能。

Default: false

registry-supports-time-field=false


附:.npmrc 文件配置模板

################# Dependency Hoisting Settings #################
################# https://pnpm.io/npmrc#dependency-hoisting-settings
# When true, all dependencies are hoisted to node_modules/.pnpm. This makes unlisted dependencies accessible to all packages inside node_modules.
hoist=true,
# Tells pnpm which packages should be hoisted to node_modules/.pnpm. By default, all packages are hoisted - however, if you know that only some flawed packages have phantom dependencies, you can use this option to exclusively hoist the phantom dependencies (recommended).
# hoist-pattern[]=*eslint*
# hoist-pattern[]=*babel*
hoist-pattern=['*']
# Unlike hoist-pattern, which hoists dependencies to a hidden modules directory inside the virtual store, public-hoist-pattern hoists dependencies matching the pattern to the root modules directory. Hoisting to the root modules directory means that application code will have access to phantom dependencies, even if they modify the resolution strategy improperly.
# string[]
# public-hoist-pattern[]=*plugin*
# public-hoist-pattern[]=*types*
# public-hoist-pattern[]=!@types/react
public-hoist-pattern=['*eslint*', '*prettier*']
# By default, pnpm creates a semistrict node_modules, meaning dependencies have access to undeclared dependencies but modules outside of node_modules do not. 
# With this layout, most of the packages in the ecosystem work with no issues.
# However, if some tooling only works when the hoisted dependencies are in the root of node_modules, you can set this to true to hoist them for you.
# Boolean
shamefully-hoist=false
################# Node-Modules Settings #################
################# https://pnpm.io/npmrc#node-modules-settings
# The location where all the packages are saved on the disk.
# The store should be always on the same disk on which installation is happening, so there will be one store per disk.
# If there is a home directory on the current disk, then the store is created inside it. If there is no home on the disk, then the store is created at the root of the filesystem.
# For example, if installation is happening on a filesystem mounted at /mnt, then the store will be created at /mnt/.pnpm-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.
store-dir=~/AppData/Local/pnpm/store
# The directory in which dependencies will be installed (instead of node_modules).
modules-dir=node_modules
# Defines what linker should be used for installing Node packages.
# Type: isolated, hoisted, pnp
# isolated - dependencies are symlinked from a virtual store at node_modules/.pnpm.
# hoisted - a flat node_modules without symlinks is created. Same as the node_modules created by npm or Yarn Classic. 
# pnp - no node_modules. Plug'n'Play is an innovative strategy for Node that is used by Yarn Berry. It is recommended to also set symlink setting to false when using pnp as your linker.
node-linker=isolated
# When symlink is set to false, pnpm creates a virtual store directory without any symlinks. It is a useful setting together with node-linker=pnp.
symlink=true
# When false, 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.
enable-modules-dir=true
# 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 instance C:\my-project-store).
# NOTE: the virtual store cannot be shared between several projects. Every project should have its own virtual store (except for in workspaces where the root is shared).
virtual-store-dir=node_modules/.pnpm
# Controls the way packages are imported from the store (if you want to disable symlinks inside node_modules, then you need to change the node-linker setting, not this one).
# Type: auto, hardlink, copy, clone, clone-or-copy
# auto - try to clone packages from the store. If cloning is not supported then hardlink packages from the store. If neither cloning nor linking is possible, fall back to copying
# hardlink - hard link packages from the store
# clone-or-copy - try to clone packages from the store. If cloning is not supported then fall back to copying
# copy - copy packages from the store
# clone - clone (AKA copy-on-write or reference link) packages from the store
package-import-method=auto
# 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.
modules-cache-max-age=10080
################# Lockfile Settings #################
################# https://pnpm.io/npmrc#lockfile-settings
# When set to false, pnpm won't read or generate a pnpm-lock.yaml file.
lockfile=true
# When set to true and the available pnpm-lock.yaml satisfies the package.json dependencies directive, a headless installation is performed. A headless installation skips all dependency resolution as it does not need to modify the lockfile.
prefer-frozen-lockfile=true
# Add the full URL to the package's tarball to every entry in pnpm-lock.yaml.
lockfile-include-tarball-url=false
################# Registry & Authentication Settings #################
################# https://pnpm.io/npmrc#registry--authentication-settings
# The base URL of the npm package registry (trailing slash included).
# The npm registry that should be used for packages of the specified scope.
# For example, setting @babel:registry=https://example.com/packages/npm/ will enforce that when you use pnpm add @babel/core, or any @babel scoped package, the package will be fetched from https://example.com/packages/npm instead of the default registry.
registry=https://registry.npmjs.org/
################# Request Settings #################
################# https://pnpm.io/npmrc#request-settings
# The Certificate Authority signing certificate that is trusted for SSL connections to the registry.
# Values should be in PEM format (AKA "Base-64 encoded X.509 (.CER)"). For example:
# ca="-----BEGIN CERTIFICATE-----\nXXXX\nXXXX\n-----END CERTIFICATE-----"
# Set to null to only allow known registrars, or to a specific CA cert to trust only that specific signing authority.
# Multiple CAs can be trusted by specifying an array of certificates:
# ca[]="..."
# ca[]="..."
# Type: String, Array or null
# Default: The npm CA certificate
# See also the strict-ssl config.
# ca= null
# 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.
cafile =null
# A client certificate to pass when accessing the registry.
# Values should be in PEM format (AKA "Base-64 encoded X.509 (.CER)"). For example:
# cert="-----BEGIN CERTIFICATE-----\nXXXX\nXXXX\n-----END CERTIFICATE-----"
# It is not the path to a certificate file (and there is no certfile option).
cert=null
# A client key to pass when accessing the registry. 
# Values should be in PEM format (AKA "Base-64 encoded X.509 (.CER)"). For example:
# key="-----BEGIN PRIVATE KEY-----\nXXXX\nXXXX\n-----END PRIVATE KEY-----"
# It is not the path to a key file (and there is no keyfile option).
# This setting contains sensitive information. Don't write it to a local .npmrc file committed to the repository.
key=null
# 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.
# Type: string[]
git-shallow-hosts=['github.com', 'gist.github.com', 'gitlab.com', 'bitbucket.com', 'bitbucket.org']
# 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.
https-proxy=null
# The IP address of the local interface to use when making connections to the npm registry.
# local-address=undefined
# 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.
proxy=null
# The maximum number of connections to use per origin (protocol/host/port combination).
# Default: network-concurrency x 3
# maxsockets=3
# A comma-separated string of domain extensions that a proxy should not be used for.
noproxy=null
# Whether or not to do SSL key validation when making requests to the registry via HTTPS.
# Default: true
strict-ssl=true
# Controls the maximum number of HTTP(S) requests to process simultaneously.
# Default: 16
network-concurrency=16
# How many times to retry if pnpm fails to fetch from the registry.
# Default: 2
fetch-retries=2
# The exponential factor for retry backoff.
# Default: 10
fetch-retry-factor=10
# The minimum (base) timeout for retrying requests.
# Default: 10000 (10 seconds)
fetch-retry-mintimeout=10000
# The maximum fallback timeout to ensure the retry factor does not make requests too long.
# Default: 60000 (1 minute)
fetch-retry-maxtimeout=60000
# The maximum amount of time to wait for HTTP requests to complete.
# Default: 60000 (1 minute)
fetch-timeout=60000
################# Peer Dependency Settings #################
################# https://pnpm.io/npmrc#peer-dependency-settings
# When true, any missing non-optional peer dependencies are automatically installed.
# Default: false
auto-install-peers=false
# If this is enabled, commands will fail if there is a missing or invalid peer dependency in the tree.
# Default: false (was true from v7.0.0 until v7.13.5)
strict-peer-dependencies=false
################# CLI Settings #################
################# https://pnpm.io/npmrc#cli-settings
# Controls colors in the output.
# Default: auto
# Type: auto, always, never
# 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.
color=auto
# Any logs at or higher than the given level will be shown. You can instead pass --silent to turn off all output logs.
# Default: info
# Type: debug, info, warn, error
loglevel=info
# 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.
# Default: false
use-beta-cli=false
# 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.
# Default: true
recursive-install=true
# 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.
engine-strict=false
# The location of the npm binary that pnpm uses for some actions, like publishing.
# npm-path= 
################# Build Settings #################
################# https://pnpm.io/npmrc#nodejs-settings
# Do not execute any scripts defined in the project package.json and its dependencies.
# This flag does not prevent the execution of .pnpmfile.cjs
ignore-scripts=false
# Do not execute any scripts of the installed packages. Scripts of the projects are executed.
# Default: false
ignore-dep-scripts=false
# The maximum number of child processes to allocate simultaneously to build node_modules.
# Default: 5
child-concurrency=5
# Use and cache the results of (pre/post)install hooks.
# Default: true
side-effects-cache=true
# Only use the side effects cache if present, do not create it for new packages.
# Default: false
side-effects-cache-readonly=false
# 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.
# Default: false IF running as root, ELSE true
unsafe-perm=false
################# Node.js Settings #################
################# https://pnpm.io/npmrc#nodejs-settings
# 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:
# Type: semver
# Default: undefined
# use-node-version=19.2.0
# 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
# Type: semver
# Default: the value returned by node -v, without the v prefix
node-version=19.2.0
# Sets the base URL for downloading Node.js.
# he <releaseDir> portion of this setting can be any directory from https://nodejs.org/download: release, rc, nightly, v8-canary, etc.
node-mirror=https://nodejs.org/download/release/
################# Workspace Settings #################
################# https://pnpm.io/npmrc#workspace-settings
# 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.
# Type: true, false, deep
link-workspace-packages=true
# 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.
# Default: false
prefer-workspace-packages=false
# 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).
# Default: true
shared-workspace-lockfile=true
# 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.
# Default: true
# Type: true, false, rolling
# https://pnpm.io/npmrc#save-workspace-protocol
save-workspace-protocol=true
# When executing commands recursively in a workspace, execute them on the root workspace project as well.
# Default: false
include-workspace-root=flase
################# Other Settings #################
################# https://pnpm.io/npmrc#other-settings
use-running-store-server=false
# 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.
save-prefix=^
# 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.
# Default: latest
# Specify a custom directory to store global packages.
tag=latest
global-dir=~/AppData/Local/pnpm/global
# Allows to set the target directory for the bin files of globally installed packages.
global-bin-dir=~/AppData/Local/pnpm
# The directory where pnpm creates the pnpm-state.json file that is currently used only by the update checker.
state-dir=~/AppData/Local/pnpm-state
# The location of the package metadata cache.
cache-dir=~/AppData/Local/pnpm-cache
# When true, all the output is written to stderr.
# Default: false
use-stderr=false
# Set to false to suppress the update notification when using an older version of pnpm than the latest.
# Default: true
update-notifier=true
# Create symlinks to executables in node_modules/.bin instead of command shims.
# This setting is ignored on Windows, where only command shims work.
# Default: true, when node-linker is set to hoisted and the system is POSIX
prefer-symlinked-executables=true
# 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.
# Default: true
verify-store-integrity=true
# 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.
# Default: false
ignore-compatibility-db=false
# When resolution-mode is set to time-based, dependencies will be resolved the following way:
# - Direct dependencies will be resolved to their lowest versions. So if there is foo@^1.1.0 in the dependencies, then 1.1.0 will be installed.
# - Subdependencies will be resolved from versions that were published before the last direct dependency was published.
# With this resolution mode installations with warm cache are faster.
# It also reduces the chance of subdependency hijacking as subdependencies will be updated only if direct dependencies are updated.
# This resolution mode works only with npm's full metadata. 
# So it is slower in some scenarios. However, if you use Verdaccio v5.15.1 or newer, you may set the registry-supports-time-field setting to true, and it will be really fast.
# Type: highest, time-based
# Default: highest
resolution-mode=highest
# 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.
# Default: false
registry-supports-time-field=false
目录
相关文章
|
7月前
|
存储 缓存 资源调度
包管理npm、yarn、pnpm区别
包管理npm、yarn、pnpm区别
76 0
|
缓存 资源调度 JavaScript
nodejs全局(npm、cnpm、yarn)及缓存基本配置,一篇就搞定
nodejs全局(npm、cnpm、yarn)及缓存基本配置,一篇就搞定
|
13天前
npm 常用指令
npm 常用指令
20 0
|
5月前
|
缓存 资源调度 前端开发
npm、yarn、pnpm 如何删除缓存文件?
在前端工程化的环境下,频繁的安装、更新、移除依赖,总会产生一些不活跃的 npm 依赖包,一直隐藏在某个角落里。
84 5
|
6月前
pnpm的安装与使用
pnpm的安装与使用
|
6月前
|
存储 资源调度 安全
你知道npm、yran、pnpm的区别吗?
你知道npm、yran、pnpm的区别吗?
44 0
|
9月前
|
JavaScript
【3】npm run build Vue的项目,如何修改相对路径配置
【3】npm run build Vue的项目,如何修改相对路径配置
|
10月前
|
存储 资源调度 安全
pnpm:基础使用
pnpm:基础使用
319 0
|
11月前
npm install hexo-renderer-sass时报错解决办法
npm install hexo-renderer-sass时报错解决办法
148 0
|
11月前
|
缓存 资源调度 前端开发
前端包管理工具 npm yarn cnpm npx(三)
前端包管理工具 npm yarn cnpm npx
130 0