.npmrc
pnpm gets its configuration from the command line, environment variables, and
.npmrc
files.
The pnpm config
command can be used to update and edit the contents of the
user and global .npmrc
files.
四個相關的檔案是:
- per-project configuration file (
/path/to/my/project/.npmrc
) - per-workspace configuration file (the directory that contains the
pnpm-workspace.yaml
file) - per-user configuration file (
~/.npmrc
) - global configuration file (
/etc/npmrc
)
All .npmrc
files are an INI-formatted list of key = value
parameters.
Values in the .npmrc
files may contain env variables using the ${NAME}
syntax. 您也可以使用預設值來指定環境變數。 Using ${NAME-fallback}
will return fallback
if NAME
isn't set. ${NAME:-fallback}
will return fallback
if NAME
isn't set, or is an empty string.
相依性提升設定
hoist
- Default: true
- Type: boolean
When true
, all dependencies are hoisted to node_modules/.pnpm/node_modules
. This makes
unlisted dependencies accessible to all packages inside node_modules
.
hoist-workspace-packages
- Default: true
- Type: boolean
When true
, 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
and public-hoist-pattern
).
hoist-pattern
- Default: ['*']
- Type: string[]
Tells pnpm which packages should be hoisted to node_modules/.pnpm/node_modules
. 預設情況下,所有套件都會提升,但是如果你知道只有一些有缺陷套件有幻影依賴關係, 您可以使用此選項來只提升有幻影依賴關係的套件 (推薦)。
例如:
hoist-pattern[]=*eslint*
hoist-pattern[]=*babel*
You may also exclude patterns from hoisting using !
.
例如:
hoist-pattern[]=*types*
hoist-pattern[]=!@types/react