feat: use global virtual store for global packages and dlx (#10694)

* feat: use global virtual store for global packages and dlx

* fix(config): remove unnecessary virtualStoreDir override for global installs

When the global virtual store is disabled, the default `node_modules/.pnpm`
path works fine — no need to explicitly override it to `.pnpm`.
This commit is contained in:
Zoltan Kochan
2026-03-01 18:03:04 +01:00
committed by GitHub
parent 9587dac9c1
commit 543c7e4bae
4 changed files with 12 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/config": major
"pnpm": major
---
Global installs (`pnpm install -g`) and `pnpm dlx` now use the global virtual store by default. Packages are stored at `{storeDir}/links` instead of per-project `.pnpm` directories. This can be disabled by setting `enableGlobalVirtualStore: false` [#10694](https://github.com/pnpm/pnpm/pull/10694).

View File

@@ -379,7 +379,9 @@ export async function getConfig (opts: {
throw new PnpmError('CONFIG_CONFLICT_VIRTUAL_STORE_DIR_WITH_GLOBAL',
'Configuration conflict. "virtual-store-dir" may not be used with "global"')
}
pnpmConfig.virtualStoreDir = '.pnpm'
if (pnpmConfig.enableGlobalVirtualStore == null) {
pnpmConfig.enableGlobalVirtualStore = true
}
} else {
pnpmConfig.dir = cwd
if (!pnpmConfig.bin) {

View File

@@ -146,6 +146,7 @@ export async function handler (
fs.mkdirSync(cachedDir, { recursive: true })
await add.handler({
...opts,
enableGlobalVirtualStore: opts.enableGlobalVirtualStore ?? true,
bin: path.join(cachedDir, 'node_modules/.bin'),
dir: cachedDir,
lockfileDir: cachedDir,

View File

@@ -335,6 +335,7 @@ test('dlx builds the package that is executed', async () => {
await dlx.handler({
...DEFAULT_OPTS,
enableGlobalVirtualStore: false,
dir: path.resolve('project'),
storeDir: path.resolve('store'),
cacheDir: path.resolve('cache'),
@@ -361,6 +362,7 @@ test('dlx builds the packages passed via --allow-build', async () => {
const allowBuild = ['@pnpm.e2e/install-script-example']
await dlx.handler({
...DEFAULT_OPTS,
enableGlobalVirtualStore: false,
allowBuild,
dir: path.resolve('project'),
storeDir: path.resolve('store'),