Mac 升级到12.3以上 python2.7 删除了
遇到的一系列问题:
1、ws 打不开webstorm
webstorm 也识别不了node路径
报错:
env: python: No such file or directory
参考:https://blog.51cto.com/u_7075695/5269502
解决办法
Python 指向 python3
➜ ln -s /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/bin/python3 /usr/local/bin/python3
➜ ln -s -f /usr/local/bin/python3 /usr/local/bin/python
没有权限加sudo
解除软连接:
sudo rm /usr/local/bin/python
2、npm I
node install.js
报错:
configure error
gyp ERR! stack Error: Command failed: /usr/local/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "<string>", line 1
就是node版本和python版本冲突
解决办法:
升级node到12.22 以上
3、M1 nvm安装node (nvm install 11.15.0)
报错:
Checksums matched! $>./configure --prefix=/Users/fangfei/.nvm/versions/node/v11.15.0 < Please use either Python 2.6 or 2.7
那是因为m1 芯片nvm安装低版本的一定要加 arch -x86_64 zsh 每安装一次都要执行该命令
解决方案:
arch -x86_64 zsh
4、NPM Error:gyp: No Xcode or CLT version detected!
gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack at ChildProcess.emit (events.js:210:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Darwin 19.3.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/yangjian/Documents/temp/test001/node_modules/fsevents
gyp ERR! node -v v12.13.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
解决方案:
$ sudo rm -rf $(xcode-select -print-path)
$ xcode-select --install
参考:https://www.cnblogs.com/zhennann/p/12272058.html
最终解决方案:
安装python2.7
下载地址: https://www.python.org/ftp/python/2.7.18/python-2.7.18-macosx10.9.pkg
直接安装就可以了
安装完成之后需要执行
npm config set python python
以上就是升级12.3以上版本之后遇到的坑。后续还遇到的话,会补充进来。