NPM安装无法在MAC中执行Python

dev*_*ato 2 python macos npm

我是 MAC 新手(OSX 版本是 High Sierra 10.13.3)。我使用 python.org 的安装程序安装了 python 3.6.5,并且我也尝试通过运行来使用 brew 来完成它brew install python。现在,我尝试sudo npm install在 Angular 项目中运行,但出现以下错误:

gyp verb check python checking for Python executable "/path/to/python3/python" in the PATH
gyp verb `which` failed Error: not found: /path/to/python3/python
gyp ERR! stack Error: Can't find Python executable "/path/to/python3/python", you can set the PYTHON env variable.
Run Code Online (Sandbox Code Playgroud)

我已经尝试过这里的所有答案:

mac osx 上的 python 位置

找不到 Python 可执行文件“python”

在我的项目文件夹中,我执行以下操作:

当我输入“which python”时,我得到:

/usr/local/opt/python/libexec/bin/python
Run Code Online (Sandbox Code Playgroud)

当我输入“which python3.6.5”时,我得到:

/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
Run Code Online (Sandbox Code Playgroud)

TRI*_*EMS 5

对我来说,这一切都是因为 Nodejs 版本而发生的。

Node版本16+不支持“node-sass”:“^4.14.1”,所以我必须安装nvm并降级macbook中的nodesjs,如下

  • 在安装 nvm 之前,请在终端中运行以下命令:touch ~/.bash_profile

  • 之后,在终端中运行:curl -o-
    https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | 巴什

  • 重要... - 不要忘记重新启动终端或使用命令 源 ~/.nvm/nvm.sh
    (这将刷新 系统路径中的可用命令)。

  • 在终端中,使用命令nvm --version你应该看到
    版本

  • bash nvm 安装 14.17.0