Skip to content

Commit 3263f61

Browse files
fix: correction to the set resolution docs (#6739)
## What's the problem this PR addresses? The example in the `set resolution` docs does not work for many packages. https://yarnpkg.com/cli/set/resolution#examples ### Issues Resolves #5979 ### Steps to reproduce: 1. Clone and `cd` to the `yarnpkg/berry` repository 2. Run `yarn set resolution lodash@npm:^4.17.11 4.16.0` 3. Observe the following error ``` yarn set resolution lodash@npm:^4.17.11 4.16.0 ➤ YN0000: · Yarn 4.7.0-dev ➤ YN0000: ┌ Resolution step ➤ YN0001: │ Error: [email protected] isn't supported by any available resolver at MultiResolver.getResolverByDescriptor (/Users/***/personal/berry/packages/yarnpkg-core/sources/MultiResolver.ts:73:13) at MultiResolver.getResolutionDependencies (/Users/***/personal/berry/packages/yarnpkg-core/sources/MultiResolver.ts:37:27) at startDescriptorResolution (/Users/***/personal/berry/packages/yarnpkg-core/sources/Project.ts:911:53) at <anonymous> (/Users/***/personal/berry/packages/yarnpkg-core/sources/Project.ts:955:57) at async startDescriptorAliasing (/Users/***/personal/berry/packages/yarnpkg-core/sources/Project.ts:896:28) ➤ YN0000: └ Completed ➤ YN0000: · Failed with errors in 0s 154ms ``` ## How did you fix it? The fix is to include npm before the resolved version, `4.16.0` -> `npm:4.16.0`. The full command will be `yarn set resolution lodash@npm:^4.17.11 npm:4.16.0`. ### Result Yarn correctly set the resolution in the yarn.lock file as follows: ``` "lodash@npm:^4.17.11": version: 4.16.0 resolution: "lodash@npm:4.16.0" checksum: 10/37d70b8a67edd4f3ef82ba3354de8dc4123ee9eddd84700a69edd3e2e3f8ae8d562162ed5af95d60810c333745c6ded9c8f432d19840387cde071ddcef5c6ec7 languageName: node linkType: hard ``` ## Checklist <!--- Don't worry if you miss something, chores are automatically tested. --> <!--- This checklist exists to help you remember doing the chores when you submit a PR. --> <!--- Put an `x` in all the boxes that apply. --> - [x] I have read the [Contributing Guide](https://yarnpkg.com/advanced/contributing). <!-- See https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released for more details. --> <!-- Check with `yarn version check` and fix with `yarn version check -i` --> - [x] I have set the packages that need to be released for my changes to be effective. <!-- The "Testing chores" workflow validates that your PR follows our guidelines. --> <!-- If it doesn't pass, click on it to see details as to what your PR might be missing. --> - [x] I will check that all automated PR checks pass before the PR gets reviewed. --------- Co-authored-by: Clement Yan <[email protected]>
1 parent ea7698a commit 3263f61

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

.yarn/versions/c0a2e918.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
releases:
2+
"@yarnpkg/cli": patch
3+
"@yarnpkg/plugin-essentials": patch
4+
5+
declined:
6+
- "@yarnpkg/plugin-compat"
7+
- "@yarnpkg/plugin-constraints"
8+
- "@yarnpkg/plugin-dlx"
9+
- "@yarnpkg/plugin-init"
10+
- "@yarnpkg/plugin-interactive-tools"
11+
- "@yarnpkg/plugin-nm"
12+
- "@yarnpkg/plugin-npm-cli"
13+
- "@yarnpkg/plugin-pack"
14+
- "@yarnpkg/plugin-patch"
15+
- "@yarnpkg/plugin-pnp"
16+
- "@yarnpkg/plugin-pnpm"
17+
- "@yarnpkg/plugin-stage"
18+
- "@yarnpkg/plugin-typescript"
19+
- "@yarnpkg/plugin-version"
20+
- "@yarnpkg/plugin-workspace-tools"
21+
- "@yarnpkg/builder"
22+
- "@yarnpkg/core"
23+
- "@yarnpkg/doctor"

packages/plugin-essentials/sources/commands/set/resolution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default class SetResolutionCommand extends BaseCommand {
2020
`,
2121
examples: [[
2222
`Force all instances of lodash@npm:^1.2.3 to resolve to 1.5.0`,
23-
`$0 set resolution lodash@npm:^1.2.3 1.5.0`,
23+
`$0 set resolution lodash@npm:^1.2.3 npm:1.5.0`,
2424
]],
2525
});
2626

0 commit comments

Comments
 (0)