.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.
The four relevant files are:
- 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.
Dependency Hoisting Settings
hoist
- Default: true
- Type: boolean
When true, all dependencies are hoisted to node_modules/.pnpm. This makes
unlisted dependencies accessible to all packages inside node_modules.
hoist-pattern
- Default: ['*']
- Type: string[]
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).
For instance:
hoist-pattern[]=*eslint*
hoist-pattern[]=*babel*
Since v7.12.0, 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[]
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.
This setting is useful when dealing with some flawed pluggable tools that don't resolve dependencies properly.
For instance:
public-hoist-pattern[]=*plugin*
Note: Setting shamefully-hoist to true is the same as setting
public-hoist-pattern to *.
Since v7.12.0, you may also exclude patterns from hoisting using !.
For instance:
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.
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.