npm安装PYTHON env

最近拉了几个GitHub的项目,好多个安装依赖的时候就报错了,其中一个node-sass的我是真没想到。

先说说npm、cnpm、yarn install的时候,同一个项目会有不同的结果,在同一个项目下: npm:

npm ERR! Found: swiper@6.8.4
npm ERR! node_modules/swiper
npm ERR! swiper@"^6.3.5" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer swiper@"^5.2.0" from vue-awesome-swiper@4.1.1
npm ERR! node_modules/vue-awesome-swiper
npm ERR! vue-awesome-swiper@"^4.1.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\dell\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\dell\AppData\Local\npm-cache_logs\2022-05-11T01_47_03_130Z-debug.log

会直接报错包的版本问题,估计yarn和cnpm的报错也会有,但是不知道为什么会报错这个。

cnpm、yarn:

 ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (C:\Users\dell\Desktop\my\lowcode\quark-h5-master\node_modules_node-gyp@3.8.0@node-gyp\lib\configure.js:484:19)
gyp ERR! stack     at PythonFinder.<anonymous> (C:\Users\dell\Desktop\my\lowcode\quark-h5-master\node_modules_node-gyp@3.8.0@node-gyp\lib\configure.js:509:16)
gyp ERR! stack     at callback (C:\Users\dell\Desktop\my\lowcode\quark-h5-master\node_modules_graceful-fs@4.2.10@graceful-fs\polyfills.js:306:20)
gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:198:21)
gyp ERR! System Windows_NT 10.0.22000
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\dell\Desktop\my\lowcode\quark-h5-master\node_modules\_node-gyp@3.8.0@node-gyp\bin\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Users\dell\Desktop\my\lowcode\quark-h5-master\node_modules_node-sass@4.14.1@node-sass
gyp ERR! node -v v16.13.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

可能旧一点的项目用的node-sass,所以需要安装Python,这个问题在之前分享的node-sass相关也有提到,只是那时候没有遇见,就没细说。
有一点挺神奇的,执行了npm、cnpm,没有删掉node_modules,居然是成功,但是启动报错一些依赖包找不到。

上面的不是重点,重点是怎么解决:
Error: Can’t find Python executable “python”, you can set the PYTHON env variable.

网上方法挺多的,能不能行还是得自己尝试,我这边说一下我的解决方法:
执行npm install --global --production windows-build-tools,然后会卡死,可以直接终止。终止之后会有一个路径:
在这里插入图片描述
C盘打开这个路径:
在这里插入图片描述
双击python-2.7.15.amd64.msi,先选择移除:
在这里插入图片描述
然后再双击python-2.7.15.amd64.msi,一路默认next直到finish。
在这里插入图片描述

成功之后再去安装依赖就不会报错了。

现在新的包应该都不用node-sass了,但是不知道其它包是否也有依赖Python的,还是得解决一下。

欢迎关注订阅号 coding个人笔记

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值