Skip to content

Commit

Permalink
fix: do not throw MISSING_HOISTED_LOCATIONS for optional packages (#6553
Browse files Browse the repository at this point in the history
)

* do not throw MISSING_HOISTED_LOCATIONS for optional packages

* docs: add changesets

---------

Co-authored-by: Douglas Ward <douglas@giantmonkey.de>
Co-authored-by: Zoltan Kochan <z@kochan.io>
  • Loading branch information
3 people committed May 16, 2023
1 parent 2866c7b commit f9f9015
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/kind-windows-reflect.md
@@ -0,0 +1,6 @@
---
"@pnpm/plugin-commands-rebuild": patch
"pnpm": patch
---

`pnpm rebuild` should not fail when `node-linker` is set to `hoisted` and there are skipped optional dependencies [#6553](https://github.com/pnpm/pnpm/pull/6553).
1 change: 1 addition & 0 deletions exec/plugin-commands-rebuild/src/implementation/index.ts
Expand Up @@ -281,6 +281,7 @@ async function _rebuild (
? (ctx.modulesFile?.hoistedLocations?.[depPath] ?? []).map((hoistedLocation) => path.join(opts.lockfileDir, hoistedLocation))
: [path.join(ctx.virtualStoreDir, dp.depPathToFilename(depPath), 'node_modules', pkgInfo.name)]
if (pkgRoots.length === 0) {
if (pkgSnapshot.optional) return
throw new PnpmError('MISSING_HOISTED_LOCATIONS', `${depPath} is not found in hoistedLocations inside node_modules/.modules.yaml`, {
hint: 'If you installed your node_modules with pnpm older than v7.19.0, you may need to remove it and run "pnpm install"',
})
Expand Down

0 comments on commit f9f9015

Please sign in to comment.