【发布时间】:2022-04-22 00:28:44
【问题描述】:
我一直在寻找这个问题的答案整整一周,但没有成功。我查看了每一篇 StackOverflow 帖子、每篇来自 Google 的文章以及我能找到的每一个相关的 Github 问题。大多数相关错误似乎都比较老,所以我想知道我的问题是否由于我在 macOS Big Sur 上而略有不同。
问题:
当我尝试在本地存储库中运行 yarn install 时,我收到与 node-gyp 相关的错误和无法找到的 python 可执行文件。这是我的终端显示的内容:
yarn install v1.22.17
...other stuff
[4/4] ???? Building fresh packages...
[6/13] ⠐ node-sass
[2/13] ⠐ node-sass
[10/13] ⠐ metrohash
[4/13] ⠐ fsevents
error /Users/jimmiejackson/Documents/repositories/repo-name/node_modules/metrohash: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /Users/jimmiejackson/Documents/repositories/repo-name/node_modules/metrohash
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@12.18.0 | darwin | x64
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "/usr/local/opt/python@3.9/bin/python3", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (/Users/jimmiejackson/Documents/repositories/repo-name/node_modules/node-gyp/lib/configure.js:484:19)
gyp ERR! stack at PythonFinder.<anonymous> (/Users/jimmiejackson/Documents/repositories/repo-name/node_modules/node-gyp/lib/configure.js:406:16)
gyp ERR! stack at F (/Users/jimmiejackson/Documents/repositories/repo-name/node_modules/which/which.js:68:16)
gyp ERR! stack at E (/Users/jimmiejackson/Documents/repositories/repo-name/node_modules/which/which.js:80:29)
gyp ERR! stack at /Users/jimmiejackson/Documents/repositories/repo-name/node_modules/which/which.js:89:16
gyp ERR! stack at /Users/jimmiejackson/Documents/repositories/repo-name/node_modules/isexe/index.js:42:5
gyp ERR! stack at /Users/jimmiejackson/Documents/repositories/repo-name/node_modules/isexe/mode.js:8:5
gyp ERR! stack at FSReqCallback.oncomplete (fs.js:167:21)
gyp ERR! System Darwin 20.6.0
gyp ERR! command "/Users/jimmiejackson/.nvm/versions/node/v12.18.0/bin/node" "/Users/jimmiejackson/Documents/repositories/repo-name/node_modules/metrohash/node_modules/.bin/node-gyp" "rebuild"
gyp ERR! cwd /Users/jimmiejackson/Documents/repositories/repo-name/node_modules/metrohash
我不完全确定这个错误是什么意思,或者为什么这个节点模块正在搜索 python3。我试过运行npm set config /path/to/python,下载python3,在我的.zshrc 配置文件中设置PYTHON 路径,但似乎没有任何效果。完全有可能我对这个问题缺乏了解,这意味着我走在正确的道路上,但没有完全得到正确的结果。有什么想法吗?
【问题讨论】:
-
你是说
export PYTHON=/usr/bin/python3没有解决这个问题? -
@TimRoberts 我假设您的意思是将其添加到我的 .zshrc 中?我的 zsh 中确实有它,但它仍然无法正常工作。
-
您应该能够在运行
yarn命令之前在命令行中键入它。如果它飞了,那么这会给你一个线索。 -
@TimRoberts 我明白了。我在终端中运行了它,不幸的是,
yarn install产生了同样的错误。 -
/usr/local/opt中的 python 由 homebrew 管理。您可以尝试至少暂时从您的PATH中删除/usr/local/opt吗?或者,您可以像这样将/usr/bin添加到您的路径中:PATH=/usr/bin:$PATH yarn install ...