NPM【问题 01】npm i [email protected]报错not found: python2及Cannot download问题处理

node-sass安装问题处理

  • 1.问题
  • 2.处理
    • [2.1 方案一【我的环境失败】](#2.1 方案一【我的环境失败】)
    • [2.2 方案二【成功】](#2.2 方案二【成功】)
    • [2.3 方案三【成功】](#2.3 方案三【成功】)

1.问题

  • gyp verb which failed Error: not found: python2
bash 复制代码
# 1.添加Python27的安装路径到环境变量
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2

# 2.未按照配置的环境变量找到python2
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python E:\anaconda3\envs\python.EXE

真实原因:

bash 复制代码
Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/win32-x64-83_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.14.1/win32-x64-83_binding.node"

2.处理

2.1 方案一【我的环境失败】

bash 复制代码
# npm设置国内地址
npm config set registry https://registry.npm.taobao.org/
npm config get registry

首先确认node的版本跟node-sass的版本是匹配的 https://github.com/sass/node-sass

bash 复制代码
# 查询node版本
node -v

# 查询结果
v14.17.0
json 复制代码
{
    ...
    "node-sass": "4.14.1",
    "sass-loader": "8.0.2",
    ...
}

解决方法,原文链接:https://blog.csdn.net/manonggeerdan/article/details/121260754

bash 复制代码
# 1.删除工程的node_modules文件夹
# 2.以管理员身份打开dos窗口
# 3.安装node-gyp
npm install -g node-gyp
# 4.安装windows-build-tools
npm install --global --production windows-build-tools

这里可能出现的问题:

Visual Studio Build Tools一直处于"Still waiting for installer log file..."状态:

bash 复制代码
Status from the installers:
---------- Visual Studio Build Tools ----------
Still waiting for installer log file...
------------------- Python --------------------
Python 2.7.8 is already installed, not installing again.

【解决】不需要等待,直接ctrl+c停止,然后输入以下命令

bash 复制代码
npm install --global --production windows-build-tools --vs2015

# 安装成功
Starting installation...
Launched installers, now waiting for them to finish.
This will likely take some time - please be patient!

---------- Visual Studio Build Tools ----------
Successfully installed Visual Studio Build Tools.
------------------- Python --------------------
Python 2.7.8 is already installed, not installing again.

Now configuring the Visual Studio Build Tools..

All done!

+ [email protected]
updated 1 package in 114.042s

然后再执行npm install

2.2 方案二【成功】

直接下载安装,复制报错信息里的地址:

bash 复制代码
Cannot download "https://github.com/sass/node-sass/releases/download/v4.14.1/win32-x64-83_binding.node"
# 使用腾讯的云服务器进行下载
wget https://github.com/sass/node-sass/releases/download/v4.14.1/win32-x64-83_binding.node

虽然很慢但是最终下载成功了!然后执行以下命令进行安装:

bash 复制代码
npm i [email protected] --sass_binary_site=E:\yuanzheng-codebase\code-gitee-open\open_ruoyi_activiti\ruoyi-deploy\ -D
  • -D 标志表示将 node-sass 安装为开发依赖项。

网盘文件分享:

链接:https://pan.baidu.com/s/1u72IgICc6EAlT4gAAr1gzg?pwd=bflf

2.3 方案三【成功】

bash 复制代码
npm i [email protected] --sass_binary_site=https://npm.taobao.org/mirrors/node-sass/ -D
相关推荐
G_GreenHand8 分钟前
Dhtmlx Gantt教程
前端
鹿九巫9 分钟前
【CSS】层叠,优先级与继承(四):层叠,优先级与继承的关系
前端·css
卓怡学长11 分钟前
w304基于HTML5的民谣网站的设计与实现
java·前端·数据库·spring boot·spring·html5
宝拉不想努力了14 分钟前
vue element使用el-table时,切换tab,table表格列项发生错位问题
前端·vue.js·elementui
YONG823_API18 分钟前
深度探究获取淘宝商品数据的途径|API接口|批量自动化采集商品数据
java·前端·自动化
鱼樱前端19 分钟前
前端必知必会:JavaScript 对象与数组克隆的 7 种姿势,从浅入深一网打尽!
前端·javascript
小希爸爸44 分钟前
1、中医基础入门和养生
前端·后端
神仙别闹2 小时前
基于VUE+Node.JS实现(Web)学生组队网站
前端·vue.js·node.js
下雨的Jim2 小时前
前端速成之——Script
前端·笔记
Captaincc2 小时前
使用 Copilot 代理模式构建着陆页
前端·ai编程·github copilot