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.
Четыре соответствующих файла:
- 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 anINI-formatted list ofkey = value
parameters.
Values in the.npmrc
files may contain env variables using the${NAME}
syntax. The env variables may also be specified with default values. Using${NAME-fallback}
will returnfallback
ifNAME
isn't set.${NAME:-fallback}
will returnfallback
ifNAME
isn't set, or is an empty string.
Dependency Hoisting Settings
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
. Bydefault, all packages are hoisted - however, if you know that only some flawedpackages have phantom dependencies, you can use this option to exclusively hoistthe phantom dependencies (recommended).
For instance:
hoist-pattern[]=*eslint*
hoist-pattern[]=*babel*
You may also exclude patterns from hoisting using!
.
For instance:
hoist-pattern[]=*types*
hoist-pattern[]=!@types/react
public-hoist-pattern
- Default:['*eslint*', '*prettier*']
- 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. Hoisting to the root modulesdirectory means that application code will have access to phantom dependencies,even if they modify the resolution strategy improperly.
This setting is useful when dealing with some flawed pluggable tools that don'tresolve dependencies properly.
For instance:
public-hoist-pattern[]=*plugin*