mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-12 10:11:42 -04:00
Closes #11488. `pnpm fetch` writes forced-empty `hoistPattern: []` and `publicHoistPattern: []` into `.modules.yaml` (because its `virtualStoreOnly` install path skips hoisting). In v10 the follow-up `pnpm install` ignored these unless the user had explicitly set a hoist-pattern in their config. v11's [#11199](https://github.com/pnpm/pnpm/pull/11199) removed that explicit-config gate, so `validateModules` now always sees the empty patterns as a hoist-pattern change and purges `node_modules` — slow on every CI run, and per the bug report sometimes leaves the modules dir in an `ERR_MODULE_NOT_FOUND` state on subsequent runs. The fix marks `.modules.yaml` with a new `virtualStoreOnly: true` field after a fetch. `validateModules` recognizes this flag as "incomplete install state" and skips the `PUBLIC_HOIST_PATTERN_DIFF` / `HOIST_PATTERN_DIFF` comparisons. The next install then completes the missing post-import linking in place rather than purging. The flag is dropped from `.modules.yaml` once a normal install runs. A genuine hoist-pattern change (without a fetch in between) still triggers the purge as before — verified manually with `publicHoistPattern` in `pnpm-workspace.yaml`.
@pnpm/installing.modules-yaml
Reads/writes `node_modules/.modules.yaml`
Installation
pnpm add @pnpm/installing.modules-yaml
Usage
import {write, read} from '@pnpm/installing.modules-yaml'
await write('node_modules', {
hoistedAliases: {},
layoutVersion: 1,
packageManager: 'pnpm@1.0.0',
pendingBuilds: [],
shamefullyFlatten: false,
skipped: [],
storeDir: '/home/user/.pnpm-store',
})
const modulesYaml = await read(`node_modules`)
API
read(pathToDir): Promise<ModulesObject>
Reads .modules.yaml from the specified directory.
write(pathToDir, ModulesObject): Promise<void>
Writes a .modules.yaml file to the specified directory.
License
MIT