Settings (.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.
関連する4つのファイルは次のとおりです。
- 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
. デフォルトでは、全てのパッケージが巻き上げられます。しかし、phantom dependency を持つ、扱いに困るパッケージの存在が分かっている場合には、こ のオプションにより、それらを除外して巻き上げることができます (推奨)。
例:
hoist-pattern[]=*eslint*
hoist-pattern[]=*babel*
You may also exclude patterns from hoisting using !
.
例:
hoist-pattern[]=*types*
hoist-pattern[]=!@types/react