How to change where pnpm installs the global packages?

Viewed 5346

Question is simple, I want to change where pnpm installs the global packages.

I have a custom Node installation on Windows and would prefer to have everything under that directory, especially as that directory is in my PATH but not the default one.

And to make it clearer I don't want to set the store dir, that's already configured and it's being created at the right place, now I would like to have the executable (*.cmd, *.ps1) and the pnpm-globals stuff in my custom dir as well.

npm already installs by default on the same directory node is located but pnpm forces on the default Roaming folder and setting prefix in etc/npmrc makes no change.

2 Answers

For pnpm v6, use global-dir instead of pnpm-prefix:

pnpm config set global-dir <dir>

Although <dir> can be arbitrary, to keep the original directory structure, it should be <your npm prefix>/pnpm-global.

From changelog:

The pnpm-prefix setting is removed. Use global-dir to specify a custom location for the globally installed packages.

Set the pnpm-prefix config with the desired location

pnpm config set pnpm-prefix <dir>
Related