当前位置: 首页 > news >正文

解决npm install报错: No module named gyp

今天运行一个以前vue项目,启动时报错如下:

 ERROR  Failed to compile with 1 error上午10:19:33

 error  in ./src/App.vue?vue&type=style&index=0&lang=scss&

Syntax Error: Error: Missing binding D:\javacode\Springboot-MiMall-RSA\VueFront\node_modules\_node-sass@4.14.1@nod         e-sass\vendor\win32-x64-83\binding.node
Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 14.x

Found bindings for the following environments:
  - Windows 64-bit with Node.js 12.x

This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to download the binding for your current environment.

大致意思是:因为我把node 12升级成了14, Node Sass库的兼容性出问题了。

我当时没多想,就把node_modules目录删除了,重新运行npm install,结果报错:

No module named gyp

 网上查了一些资料说解决办法如下:

1. 指定python2.7路径:npm config set python python2.7

2.    运行:npm install –no-optional

以上参考:https://spin.atomicobject.com/2019/03/27/node-gyp-windows/

 但是两个方法都试过了,全部无效。

后来在一篇文章:node-sass,sass-loader,node-gyp,node报错,版本对应问题

 找到解决办法: 原来node版本跟node-sass有对应关系:

我之前的node-sass版本是4.12.0,把它修改成4.14.1 ,然后重新npm install就解决问题了

 

 此时我突然想起我启动时第一次的报错:

RSA\VueFront\node_modules\_node-sass@4.14.1@nod         e-sass\vendor\win32-x64-83\binding.node
Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 14.x

Found bindings for the following environments:
  - Windows 64-bit with Node.js 12.x

This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to download the binding for your current environment.

 上面的提示其实写清楚了需要node-sass@4.14.1来匹配Node.js 14.x,建议修复命令:npm rebuild node-sass来修复。

我在想如果一开始我就运行:npm rebuild node-sass 这跟命令,也许问题就解决了

http://www.lryc.cn/news/151321.html

相关文章:

  • Leetcode 面试题 17.01 不用加号的加法
  • 一个 MySQL 数据库死锁的案例和解决方案
  • AMBEO 双声道空间音频现已迈进直播制作领域
  • 在VSCode上画UML的三个插件
  • Springboot - 1.什么是springboot
  • 学习微信小程序 Westore
  • CentOS上使用Docker安装和部署kkFileView
  • Level-based Foraging 多智能体游戏仿真环境
  • LeetCode-53-最大子数组和-贪心算法
  • 解决gitee仓库中 .git 文件夹过大的问题
  • uniapp 开发小程序,封装一个方法,让图片使用线上地址
  • Android 12 源码分析 —— 应用层 三(SystemUIFactory及其Dependency解析)
  • 考前冲刺上岸浙工商MBA的备考经验分享
  • XmlDocument.SelectNodes 不起作用
  • 部署单点elasticsearch
  • ElementUI浅尝辄止16:Tag 标签
  • Java虚拟机(JVM)框架
  • 配置Publisher 的编译规则
  • 【SpringBoot】接口实现:SpringBoot实现博客系统的文章列表页接口代码
  • 如何使用SQL系列 之 如何在SQL中插入数据
  • 【LeetCode题目详解】1281题 整数的各位积和之差 面试题 01.01. 判定字符是否唯一 python题解(作业一二)
  • 1.12 进程注入ShellCode套接字
  • MySQL 日志系统
  • LeetCode刷题---Two Sum(一)
  • 算法通关村第十七关——插入区间
  • Jenkins java8安装版本安装
  • 线上问诊:数仓开发(二)
  • Ansible自动化运维工具(三)
  • ChatGPT在创新和创业中的应用如何?
  • Log4j2 配置日志记录发送到 kafka 中