$ npm install yarn@3
npm ERR! code ETARGET
npm ERR! notarget No matching version found for yarn@3.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ubuntu/.npm/_logs/2023-08-06T14_28_15_136Z-debug-0.log
That log file has a bit more detail:
48 verbose stack yarn: No matching version found for yarn@3.
48 verbose stack at module.exports (/home/ubuntu/.nvm/versions/node/v16.20.1/lib/node_modules/npm
/node_modules/npm-pick-manifest/lib/index.js:209:23)
48 verbose stack at RegistryFetcher.manifest (/home/ubuntu/.nvm/versions/node/v16.20.1/lib/node_m
odules/npm/node_modules/pacote/lib/registry.js:125:22)
48 verbose stack at async Arborist.[nodeFromEdge] (/home/ubuntu/.nvm/versions/node/v16.20.1/lib/n
ode_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1061:19)
48 verbose stack at async Arborist.[buildDepStep] (/home/ubuntu/.nvm/versions/node/v16.20.1/lib/n
ode_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:930:11)
48 verbose stack at async Arborist.buildIdealTree (/home/ubuntu/.nvm/versions/node/v16.20.1/lib/n
ode_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:211:7)
48 verbose stack at async Promise.all (index 1)
48 verbose stack at async Arborist.reify (/home/ubuntu/.nvm/versions/node/v16.20.1/lib/node_modul
es/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:154:5)
48 verbose stack at async Install.exec (/home/ubuntu/.nvm/versions/node/v16.20.1/lib/node_modules
/npm/lib/commands/install.js:145:5)
48 verbose stack at async module.exports (/home/ubuntu/.nvm/versions/node/v16.20.1/lib/node_modul
es/npm/lib/cli.js:78:5)
% yarn set version stable
warning package.json: No license field
➤ YN0000: Retrieving https://repo.yarnpkg.com/3.6.3/packages/yarnpkg-cli/bin/yarn.js
➤ YN0000: Saving the new release in .yarn/releases/yarn-3.6.3.cjs
➤ YN0000: Done in 0s 326ms
% yarn set version 3
➤ YN0000: Retrieving https://repo.yarnpkg.com/3.6.3/packages/yarnpkg-cli/bin/yarn.js
➤ YN0000: Saving the new release in .yarn/releases/yarn-3.6.3.cjs
➤ YN0000: Done in 0s 286ms
% yarn install
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed in 0s 409ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ yarn@npm:1.22.19 can't be found in the cache and will be fetched from the remote registry
➤ YN0000: └ Completed in 0s 835ms
➤ YN0000: ┌ Link step
➤ YN0031: │ One or more node_modules have been detected and will be removed. This operation may take some time.
➤ YN0007: │ yarn@npm:1.22.19 must be built because it never has been before or the last one failed
➤ YN0000: └ Completed in 0s 451ms
➤ YN0000: Done with warnings in 1s 700ms
% yarn -v
3.6.3
% npm cache clean --force
npm WARN using --force Recommended protections disabled.
% npm install yarn@3
npm ERR! code ETARGET
npm ERR! notarget No matching version found for yarn@3.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
claus@dev12 ~ $ npm install -g yarn
added 1 package, and audited 2 packages in 1s
found 0 vulnerabilities
claus@dev12 ~ $ yarn set version 3.x
warning package.json: No license field
Resolving 3.x to a url...
error An unexpected error occurred: "Release not found: 3.x".
info If you think this is a bug, please open a bug report with the information provided in "/srv/data/home/claus/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/policies for documentation about this command.
Instead following commands worked
claus@dev12 ~ $ corepack prepare yarn@3.6.3 --activate
Preparing yarn@3.6.3 for immediate activation...
claus@dev12 ~ $ yarn set version 3.6.3
➤ YN0000: Retrieving https://repo.yarnpkg.com/3.6.3/packages/yarnpkg-cli/bin/yarn.js
➤ YN0000: Saving the new release in .yarn/releases/yarn-3.6.3.cjs
➤ YN0000: Done in 0s 797ms
claus@dev12 ~ $ yarn -v
3.6.3
had intitially the same issue with just npm install yarn@3
This worked for me today on macOS Ventura from the instructions above:
yarn set version stable
# gave
➤ YN0000: Retrieving https://repo.yarnpkg.com/4.0.2/packages/yarnpkg-cli/bin/yarn.js
➤ YN0000: Saving the new release in .yarn/releases/yarn-4.0.2.cjs
# then
yarn set version 3
npm install yarn