I accidentally added a random "Z" in the yarn.lock and got this exact error. The error pointed at line 51, but the Z was way down in the middle of the file. Checking for typos is a good first step if you get this error.
Originally posted by @kylezeeuwen in yarnpkg/yarn#6152 (comment)