.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.yamlfile) - 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
public-hoist-pattern
- Default: ['*eslint*', '*prettier*']
 - Type: string[]
 
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. ルートのモジュールディレクトリへの巻き上げによって、アプリケーションのコードは phantom dependencies へアクセスできるようになります。たとえ依存関係の解決方法が不適切に変更されたとしてもアクセス可能です。
この設定は、依存関係を適切に解決していなくて扱いに困る、プラグイン可能なツールを利用する場合に便利です。
例:
public-hoist-pattern[]=*plugin*
Note: Setting shamefully-hoist to true is the same as setting
public-hoist-pattern to *.
You may also exclude patterns from hoisting using !.
例:
public-hoist-pattern[]=*types*
public-hoist-pattern[]=!@types/react
shamefully-hoist
- Default: false
 - Type: Boolean
 
By default, pnpm creates a semistrict node_modules, meaning dependencies have
access to undeclared dependencies but modules outside of node_modules do not.
エコシステム内のほとんどのパッケージは、この方法で問題なく動作します。
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.
node_modules に関する設定
modules-dir
- Default: node_modules
 - Type: path
 
The directory in which dependencies will be installed (instead of
node_modules).
node-linker
- Default: isolated
 - Type: isolated, hoisted, pnp
 
Node.js のパッケージをインストールするのに使用するリンカーを指定します。
- isolated - dependencies are symlinked from a virtual store at 
node_modules/.pnpm. - hoisted - a flat 
node_moduleswithout symlinks is created. Same as thenode_modulescreated by npm or Yarn Classic. この設定を使用すると、Yarnのライブラリーの 1 つが巻き上げに使用されます。 この設定を使用す る合理的な理由は以下のとおりです:- 使っているツールはシンボリックリンクではうまく機能しない。 A React Native project will most probably only work if you use a hoisted 
node_modules. - プロジェクトがサーバーレスホスティングにデプロイされる。 一部のサーバーレスサービスの提供者 (AWS Lambdaなど) はシンボリックリンクをサポートしていません。 この問題を解決する代替策は、デプロイ前にアプリケーションをバンドルすることです。
 - If you want to publish your package with 
"bundledDependencies". - If you are running Node.js with the --preserve-symlinks flag.
 
 - 使っているツールはシンボリックリンクではうまく機能しない。 A React Native project will most probably only work if you use a hoisted 
 - pnp - no 
node_modules. Plug'n'Play is an innovative strategy for Node that is used by Yarn Berry. It is recommended to also setsymlinksetting tofalsewhen usingpnpas your linker. 
symlink
- Default: true
 - Type: Boolean
 
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.