我正在尝试执行npm安装,但在应用程序中出现错误
系统详情:macOS Monterey:版本12.5
苹果M1 Pro
节点版本:14.19.3
node-gyp版本:9.1.0
Python版本:3.8.9
> snappy@6.3.5 install /Users/sanhp/client-access-portal/node_modules/snappy
> prebuild-install || node-gyp rebuild
prebuild-install WARN install No prebuilt binaries found (target=14.19.3 runtime=node arch=arm64 libc= platform=darwin)
CXX(target) Release/obj.target/snappy/deps/snappy/snappy-1.1.7/snappy-sinksource.o
CXX(target) Release/obj.target/snappy/deps/snappy/snappy-1.1.7/snappy-stubs-internal.o
CXX(target) Release/obj.target/snappy/deps/snappy/snappy-1.1.7/snappy.o
LIBTOOL-STATIC Release/snappy.a
env: python: No such file or directory
make: *** [Release/snappy.a] Error 127
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/sanhp/.nvm/versions/node/v14.19.3/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:400:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:285:12)
gyp ERR! System Darwin 21.6.0
gyp ERR! command "/Users/sanhp/.nvm/versions/node/v14.19.3/bin/node" "/Users/sanhp/.nvm/versions/node/v14.19.3/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/sanhp/client-access-portal/node_modules/snappy
gyp ERR! node -v v14.19.3
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
字符串
3条答案
按热度按时间ymdaylpp1#
问题是macos 12中缺少默认的python。Npm实际上告诉你
env:python:没有这样的文件或目录
要解决这个问题,你需要创建一个python符号链接,如下所示:
对于安装了python3的homebrew:
字符串
对于任何python3:
型
有关详细信息,请参阅:https://namespaceit.com/blog/env-python-no-such-file-or-directory-when-building-app-with-xcode
b4qexyjb2#
npm install抱怨在环境中找不到python。要确认这一点,请运行以下命令
字符串
你应该得到一个命令没有发现异常。要解决这个问题,请安装python,然后运行上面的命令会告诉你安装的python版本。一些版本的python有一个稍微不同的二进制名称,例如python3,所以我建议你安装pyenv,它可以用来管理多个版本的python。按照README中的说明安装pyenv和python。一旦上一个命令返回python版本,您可以再次尝试'npm install'。
whlutmcx3#
通过执行以下命令创建Python虚拟环境:
字符串
现在您应该能够运行
python --version
并重新运行npm install
。