PNPM is an efficient package manager that saves disk space and accelerates dependency installation by utilizing hard links and symbolic links. By default, PNPM sets the global directory within a subdirectory of the user's home directory. However, users may need to change this location for reasons such as disk space constraints or multi-user sharing requirements.
To modify PNPM's global directory, set the environment variable PNPM_HOME. Here are the specific steps:
-
Find the Current Global Directory: Before making changes, run the following command to locate the current global directory path:
bashpnpm config get global-dir -
Set the
PNPM_HOMEEnvironment Variable: ConfigurePNPM_HOMEin your shell configuration file (e.g.,.bashrc,.zshrc, or other relevant files) to point to the new directory. For example:bashexport PNPM_HOME="/new/path/to/global" -
Apply the Changes: After updating the configuration file, reload it or restart your terminal to apply the changes. Reload the configuration file using:
bashsource ~/.bashrc # or the corresponding configuration file -
Verify the Change: After setting the environment variable, running
pnpm config get global-diragain will display the new global directory path.
This successfully modifies PNPM's global directory location, enabling better disk resource management and customizable configuration based on specific needs.