npm安装依赖报错——npm ERR gyp verb cli的解决方法 Node Sass version 7.0.1 is incompatible with ^4.0.0. 因为在此系统上禁止运

时间:2025-02-13 07:47:53

文章目录

  • `必须进行的操作`
  • `优先解决方案`
  • 安装依赖报错——npm ERR! gyp verb cli的解决方法
  • Sass version 7.0.1 is incompatible with ^4.0.0
  • 3.因为禁止在此系统上运行此脚本

必须进行的操作

无论是什么webpack问题,都请先执行这几步

# npm指令清除npm缓存
npm cache clean --force

# 手动删除node_module包.     package_lock.json可以不删

# 使用国内淘宝镜像
npm install -g cnpm --registry=https://registry.npm.taobao.org
npm install -g mirror-config-china --registry=https://registry.npmmirror.com

优先解决方案

不要使用最新版nodejs,最新版nodejs和webpack镜像源的内容一般不匹配,容易出现sass,scss报错!!!!!!!!!
cnpm install

安装依赖报错——npm ERR! gyp verb cli的解决方法

错误描述
gyp verb cli xxx
gyp verb which failed xxxx
gyp ERR! stack xxxx
npm ERR! xxxx

解决方案
执行完文章首部的命令后

node14以下的版本支持node-sass,版本node16以上的不再支持node-sass,而sass官网推荐安装npm install sass替代node-sass

# npm uninstall sass 
npm install node-sass
npm install

即可解决该问题,如果说npm install node-sass命令报错,则你没有听我的话,没有执行文章开始的命令.

Sass version 7.0.1 is incompatible with ^4.0.0

引用sass模块,但与node版本不兼容

npm uninstall node-sass
npm i -D sass

3.因为禁止在此系统上运行此脚本

可以在powerShell中输入

set-executionpolicy remotesigned