Cannot find module ‘node-sass‘或者check python checking for Python executable python2 in the PATH的方案汇总

事情发生在一个平常的工作日,拉取一个老项目,发现npm i 报错了,无法安装依赖,报错

报错ONE

check python checking for Python executable python2 in the PATH:如下:

很多博主的解决方案如下:
一、node与node-sass的版本不对应,修改成对应的node-sass,重新npm i 便可以,如下:
以此文为例

二、安装了 python2.7 和 windows-build-tools后,重新安装依赖
以此文为例

npm install --global windows-build-tools --save

以上两种方法并不合适我这情况,因此我直接运行项目 npm run dev,发现出了新的报错

报错TWO

Module build failed: Error: Cannot find module ‘node-sass’,如下

输入 npm install node-sass –save-dev,发现又报回check python checking for Python executable python2 in the PATH错误

解决方案
一、使用淘宝镜像安装依赖
①使用淘宝镜像安装cnpm

npm install -g cnpm --registry=https://registry.npm.taobao.org 

②使用cnpm下载node-sass

cnpm install node-sass --save

完成后,npm run dev就可以了
以此文为例

但该方法,对于我这项目也无法解决

二、使用淘宝临时镜像全局安装mirror-config-china

①全局配置,安装mirror-config-china (这里用淘宝临时镜像)

npm install -g mirror-config-china --registry=https://registry.npmmirror.com

②安装依赖node-sass

npm install node-sass

最后的最后,npm run dev,终于成功跑起来了!!!
喜极而泣,先哭为敬~~

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
扎眼的阳光的头像扎眼的阳光普通用户
上一篇 2023年12月21日
下一篇 2023年12月21日

相关推荐