我在node-gyp
包方面遇到了一些问题,并且我认为这是因为我需要使用python 2.7而不是python 3。
我已经设置了PATH环境变量,以便在执行python --version
时输出为Python 2.7.16
。
但是,在同一终端中,当我转到yarn
时,请安装我的项目。它失败了,我可以看到日志的输出是:
Command: node-gyp rebuild
Arguments:
Directory: /Users/myname/Documents/myproject
Output:
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info find Python using Python version 3.7.3 found at "/Users/myname/anaconda3/bin/python"
我也在使用nvm。卡塔琳娜10.15.2。节点12.14.0。 NVM 0.33.11。
为什么我的终端版本显示我使用2.7,但是日志显示命令node-gyp rebuild
使用3.7.3?如果我已经设置了环境变量,该如何更改以纠正此问题?与nvm有关吗?
已解决!您可以这样做:
npm install --python=python2.7
或将其设置为始终使用:
npm config set python python2.7
从这里捏=> How to use a different version of python during NPM install?