How to resolve yarn error: Invalid violation: Expected a key

How to resolve yarn error: Invalid violation: Expected a key

我遇到了 yarn 的一些问题。因此通过自制软件(mac)卸载并重新安装它。现在 运行 上的任何纱线命令都会出现以下错误(即使在 yarn -v 上)

Invariant Violation: Expected a key
    at invariant (/usr/local/Cellar/yarn/1.22.15/libexec/lib/cli.js:2314:15)
    at Parser.parse (/usr/local/Cellar/yarn/1.22.15/libexec/lib/cli.js:64434:55)
    at parse (/usr/local/Cellar/yarn/1.22.15/libexec/lib/cli.js:64581:21)
    at module.exports.exports.default (/usr/local/Cellar/yarn/1.22.15/libexec/lib/cli.js:64143:96)
    at loadRcFile (/usr/local/Cellar/yarn/1.22.15/libexec/lib/cli.js:56986:58)
    at /usr/local/Cellar/yarn/1.22.15/libexec/lib/cli.js:56960:14
    at /usr/local/Cellar/yarn/1.22.15/libexec/lib/cli.js:101468:14
    at Array.map (<anonymous>)
    at parseRcPaths (/usr/local/Cellar/yarn/1.22.15/libexec/lib/cli.js:101466:78)
    at Object.findRc (/usr/local/Cellar/yarn/1.22.15/libexec/lib/cli.js:101480:10)

因为 none 的 yarn 命令正在运行,所以也无法清除 yarn 缓存。如何解决这个问题?

运行 今天遇到同样的问题,原来是 yarn.lock 文件中的空字符串引起的:

"@dockite/field@>= 1.1.14", "", "@dockite/field@^1.1.0","@dockite/field@^1.1.33":