fix: clarify non-root resolutions warning (#11912)

This commit is contained in:
mehmet turac
2026-05-25 13:31:17 +03:00
committed by GitHub
parent 494cdcaa01
commit e8b3ae132e
3 changed files with 11 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/workspace.projects-reader": patch
---
Clarify that non-root `resolutions` does not take effect and dependency overrides should be configured with `overrides` in `pnpm-workspace.yaml`.

View File

@@ -71,8 +71,12 @@ function checkNonRootProjectManifest ({ manifest, rootDir }: Project): void {
}
function printNonRootFieldWarning (prefix: string, propertyPath: string): void {
const message = propertyPath === 'resolutions'
? `The field "${propertyPath}" was found in ${prefix}/package.json. This will not take effect. Configure dependency overrides in pnpm-workspace.yaml using the "overrides" field instead.`
: `The field "${propertyPath}" was found in ${prefix}/package.json. This will not take effect. You should configure "${propertyPath}" at the root of the workspace instead.`
logger.warn({
message: `The field "${propertyPath}" was found in ${prefix}/package.json. This will not take effect. You should configure "${propertyPath}" at the root of the workspace instead.`,
message,
prefix,
})
}

View File

@@ -49,6 +49,6 @@ test('findWorkspaceProjects() outputs warnings for non-root workspace project',
jest.mocked(logger.warn).mock.calls
.sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)))
).toStrictEqual([
[{ prefix: barPath, message: `The field "resolutions" was found in ${barPath}/package.json. This will not take effect. You should configure "resolutions" at the root of the workspace instead.` }],
[{ prefix: barPath, message: `The field "resolutions" was found in ${barPath}/package.json. This will not take effect. Configure dependency overrides in pnpm-workspace.yaml using the "overrides" field instead.` }],
])
})