Xcode yarn:没有找到命令



当我在Xcode上构建应用程序时收到一个错误:

/bin/sh: yarn: command not found
make: *** [LocalMediaPicker/Sources/LocalMediaPicker/Generated/i18n.stamp] Error 127
Command PhaseScriptExecution failed with a nonzero exit code

但我运行which yarn在终端得到/opt/homebrew/bin/yarn,不知道为什么Xcode找不到yarn

Xcode版本:version 13.4.1 (13F100)

纱线版本:1.22.17

OS: Monterey Version 12.3

更新:尝试npm i -g yarn

> yarn@1.22.19 preinstall /opt/homebrew/lib/node_modules/yarn
> :; (node ./preinstall.js > /dev/null 2>&1 || true)
npm ERR! code EEXIST
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/yarn/bin/yarn.js
npm ERR! dest /opt/homebrew/bin/yarn
npm ERR! errno -17
npm ERR! EEXIST: file already exists, symlink '../lib/node_modules/yarn/bin/yarn.js' -> '/opt/homebrew/bin/yarn'
npm ERR! File exists: /opt/homebrew/bin/yarn
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

yarn安装在构建阶段脚本所使用的PATH之外的位置。我能想到有两种方法来修改脚本,使其正常工作。


在调用yarn之前,将包含可执行文件的路径添加到脚本将使用的PATH中。

export PATH="$PATH:/opt/homebrew/bin"

yarn ...

使用可执行文件的完整路径而不是名称调用yarn

/opt/homebrew/bin/yarn ...
sudo npm install -g npm

然后

sudo nom install -g yarn

重启系统这对我很有效。这可能是映射的问题,所以这可能是你的问题。