首页 前端知识 npm版本太低npm i的时候报错,node-sass安装报错

npm版本太低npm i的时候报错,node-sass安装报错

2024-09-10 23:09:16 前端知识 前端哥 983 773 我要收藏

npm版本8.11.4

当安装项目依赖npm i的时候出现

Error: Can't find Python executable "python", you can set the PYTHON env variable.

是因为node-sass安装问题,重新装一下node-sass可解决

在安装node-sass的时候遇到如下问题

gyp ERR! stack Error: ENOENT: no such file or directory, mkdir 'C:\Users\admin\AppData\Local\node-gyp\Cache\8.11.4'

这是由于走了本地编译,本地没有python,走淘宝镜像安装 将npm镜像换成淘宝最新镜像,注意一定是淘宝最新镜像:执行npm config set registry https://registry.npmmirror.com

以上最好可以在npmrc文件里面,用vscode打开

将里面的内容全部替换为

# mirror config sharp_binary_host = https://npmmirror.com/mirrors/sharp sharp_libvips_binary_host = https://npmmirror.com/mirrors/sharp-libvips profiler_binary_host_mirror = https://npmmirror.com/mirrors/node-inspector/ fse_binary_host_mirror = https://npmmirror.com/mirrors/fsevents node_sqlite3_binary_host_mirror = https://npmmirror.com/mirrors sqlite3_binary_host_mirror = https://npmmirror.com/mirrors sqlite3_binary_site = https://npmmirror.com/mirrors/sqlite3 sass_binary_site = https://npmmirror.com/mirrors/node-sass electron_mirror = https://npmmirror.com/mirrors/electron/ puppeteer_download_host = https://npmmirror.com/mirrors chromedriver_cdnurl = https://npmmirror.com/mirrors/chromedriver operadriver_cdnurl = https://npmmirror.com/mirrors/operadriver phantomjs_cdnurl = https://npmmirror.com/mirrors/phantomjs python_mirror = https://npmmirror.com/mirrors/python registry = https://registry.npmmirror.com disturl = https://npmmirror.com/dist

然后安装对应版本号的windows-build-tools,执行命令npm install --global windows-build-tools@4.0.0安装完python,部分失败先不管

然后安装对应版本的node-sass,先将之前的node-modules全部删掉再安装【注意一定都要是对应版本,因为npm版本太低了】

执行npm install node-sass@4.5.3  --save-dev 安装node-sass成功了

执行完之后执行npm i还是报错,发现是因为项目里面package-lock.json里面node-sass写了1.13.1版本,将node-sass版本号全部改为4.5.3

然后执行npm i 成功

转载请注明出处或者链接地址:https://www.qianduange.cn//article/18127.html
标签
评论
发布的文章

jQuery 选择器

2024-05-12 00:05:34

cdn引入前端插件

2024-10-13 20:10:14

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!