npm install 时出现 Could not find any Python installation to use
2022-03-05 14:58:00
在使用 npm
或者 cnpm
安装依赖时经常会出现各种问题(我用的cnpm),版本问题,源问题等等
上述错误说找不到 Python
,很多人(我)就会感到奇怪,为啥前端依赖还要 Python ,这是因为我们有些模块编译需要用到 node-gyp
去构建一些模块, GYP 是基于 Python 2 开发的,所以需要 Python,而且不支持 3
解决方案:全局安装 node-gyp ,然后重新安装依赖即可
1 | npm install -g node-gyp |
推荐一个稳定版本
node v14.15
cnpm 6.1.1
1 npm install -g cnpm@6.1.1 --registry=https://registry.npm.taobao.org