Install Node.js using the official NodeSource repository for the latest LTS version.
Using NodeSource
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -\napt install nodejs -yVerify
node -v\nnpm -vUsing nvm (Node Version Manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash\nsource ~/.bashrc\nnvm install --lts\nnvm use --ltsInstall Yarn
npm install -g yarn