mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-27 10:30:58 -04:00
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:
6
.changeset/global-install-virtual-store.md
Normal file
6
.changeset/global-install-virtual-store.md
Normal 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).
|
||||
@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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'),
|
||||
|
||||
Reference in New Issue
Block a user