Installing yarnpkg on Debian 11 (bullseye)

To install (currently installs version 1.22.10):

mkdir -p ~/src/yarn
cd ~/src/yarn
sudo apt install npm
npm install yarn
sudo ln -s "$PWD/node_modules/yarn/bin/yarnpkg" /usr/bin/yarnpkg

You should check that the SHA256 reported of the cli.js file is the same as the file downloaded from https://yarnpkg.com/package/yarn?files

wget https://cdn.jsdelivr.net/npm/yarn@1.22.10/lib/cli.js
sha256sum cli.js node_modules/yarn/lib/cli.js 
defb0fe75a912a939852526658f6e7c09171c773f384e6add1c92a13112e0d0e cli.js
defb0fe75a912a939852526658f6e7c09171c773f384e6add1c92a13112e0d0e node_modules/yarn/lib/cli.js
rm cli.js

To upgrade:

cd ~/src/yarn
yarnpkg upgrade