Sunday, July 3, 2022

Yarn 2 and Yarn 3 Unrecognized or legacy configuration settings found

If you get this error

Unrecognized or legacy configuration settings found

while running Yarn 2 or Yarn 3 it's possibly because you have a rogue environment variable YARN_XXXX in your environment

In my case, it was a YARN_WORKSPACES environment variable I accidentally created while using the Netlify BaaS that I was supposed to create with NETLIFY_YARN_WORKSPACES

Delete the rogue environment variable (in this case from Netlify's Build GUI but in other cases could be from your Dockerfile or CI/CD pipeline) and your problem will disappear

Basically yarn is a busybody and if it sees YARN_XXXXXX in your environment, it will complain if it doesn't recognise the environment variable and fail your build

I discovered this by modifying the build command to use yarn config -v to see the list of errors and it was an undocumented yarn error code

See for another Netlify configuration error

Hope this helps someone!