Fix Option 1: Update Yarn and Node
The first thing to do if you have this error is to update the yarn command to the latest version as well as Node Js to the latest LTS version. Often times this will do the trick and you will be able to run the yarn command as you normally would.
If you are on macOS then you might be using homebrew so here's the update command for yarn and node.
brew upgrade yarn brew upgrade node
Fix Option 2: Using some Voodoos
The second fix is to try some voodoo.
1st - Delete any "*.lock" and rm node_modules or rm -rf node_modules/
rm node_modules/ rm -rf node_modules/
Run the terminal commands below: (run the command one line at a time)
set http_proxy= set https_proxy= yarn config delete proxy npm config rm https-proxy npm config rm proxy npm config set registry "https://registry.npmjs.org"
yarn yarn add mypckge --network-timeout 100000 yarn --network-timeout 100000