fix: rebuild should print a better error message (#5819)

close #5815
This commit is contained in:
Zoltan Kochan
2022-12-23 01:36:58 +02:00
committed by GitHub
parent d7ea8b486a
commit 5c75ff3ec6
6 changed files with 25 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/plugin-commands-rebuild": patch
"pnpm": patch
---
`pnpm rebuild` should not fail if node_modules was created by pnpm version 7.18 or older [#5815](https://github.com/pnpm/pnpm/issues/5815).

View File

@@ -0,0 +1,6 @@
---
"@pnpm/plugin-commands-rebuild": patch
"pnpm": patch
---
`pnpm rebuild` should print a better error message when a hoisted dependency is not found [#5815](https://github.com/pnpm/pnpm/issues/5815).

View File

@@ -34,6 +34,7 @@
"homepage": "https://github.com/pnpm/pnpm/blob/main/exec/plugin-commands-rebuild#readme",
"devDependencies": {
"@pnpm/assert-project": "workspace:*",
"@pnpm/error": "workspace:*",
"@pnpm/filter-workspace-packages": "workspace:*",
"@pnpm/plugin-commands-rebuild": "workspace:*",
"@pnpm/prepare": "workspace:*",

View File

@@ -4,6 +4,7 @@ import {
WANTED_LOCKFILE,
} from '@pnpm/constants'
import { skippedOptionalDependencyLogger } from '@pnpm/core-loggers'
import { PnpmError } from '@pnpm/error'
import { getContext, PnpmContext } from '@pnpm/get-context'
import {
runLifecycleHooksConcurrently,
@@ -276,6 +277,11 @@ async function _rebuild (
const pkgRoots = opts.nodeLinker === 'hoisted'
? (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) {
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"',
})
}
const pkgRoot = pkgRoots[0]
try {
const extraBinPaths = ctx.extraBinPaths

View File

@@ -48,6 +48,9 @@
{
"path": "../../packages/dependency-path"
},
{
"path": "../../packages/error"
},
{
"path": "../../packages/types"
},

3
pnpm-lock.yaml generated
View File

@@ -1046,6 +1046,9 @@ importers:
'@pnpm/assert-project':
specifier: workspace:*
version: link:../../__utils__/assert-project
'@pnpm/error':
specifier: workspace:*
version: link:../../packages/error
'@pnpm/filter-workspace-packages':
specifier: workspace:*
version: link:../../workspace/filter-workspace-packages