• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

node install编译失败原因

武飞扬头像
木芒果呀
帮助1

关键报错信息

  1.  
    npm ERR! gyp verb check python checking for Python executable "python2.7" in the PATH
  2.  
    npm ERR! gyp verb `which` failed Error: not found: python2.7

或者

  1.  
    npm ERR! code ERESOLVE
  2.  
    npm ERR! ERESOLVE could not resolve
  3.  
    npm ERR!
  4.  
    npm ERR! While resolving: sass-loader@8.0.2
  5.  
    npm ERR! Found: node-sass@6.0.1
  6.  
    npm ERR! node_modules/node-sass
  7.  
    npm ERR! dev node-sass@"^6.0.1" from the root project
  8.  
    npm ERR!
  9.  
    npm ERR! Could not resolve dependency:
  10.  
    npm ERR! peerOptional node-sass@"^4.0.0" from sass-loader@8.0.2
  11.  
    npm ERR! node_modules/sass-loader
  12.  
    npm ERR! dev sass-loader@"^8.0.2" from the root project
  13.  
    npm ERR!
  14.  
    npm ERR! Conflicting peer dependency: node-sass@4.14.1
  15.  
    npm ERR! node_modules/node-sass
  16.  
    npm ERR! peerOptional node-sass@"^4.0.0" from sass-loader@8.0.2
  17.  
    npm ERR! node_modules/sass-loader
  18.  
    npm ERR! dev sass-loader@"^8.0.2" from the root project
  19.  
    npm ERR!
  20.  
    npm ERR! Fix the upstream dependency conflict, or retry
  21.  
    npm ERR! this command with --force, or --legacy-peer-deps
  22.  
    npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
学新通

解决方案

请确保你有Python2的环境后,那么都是由于node.js的版本与node-sass和sass-loader版本互相不兼容导致!

Python2下载连接:https://www.python.org/ftp/python/2.7.18/python-2.7.18.amd64.msi,安装完成打开cmd命令行输入python查看是否有Python2的环境

学新通

官网解释:node-sass - npm

NodeJS版本 支持的node-sass版本 Node Module版本
Node 19 8.0 111
Node 18 8.0 108
Node 17 7.0 , <8.0 102
Node 16 6.0 93
Node 15 5.0 , <7.0 88
Node 14 4.14 83
Node 13 4.13 , <5.0 79
Node 12 4.12 , <8.0 72
Node 11 4.10 , <5.0 67
Node 10 4.9 , <6.0 64
Node 8 4.5.3 , <5.0 57
Node <8 <5.0 <57

1.如果你是Node16版本的话,可以参考以下修改方案,打开项目的package.json文件,找到node-sass和sass-loader

  1.  
    "node-sass": "^6.0.1",
  2.  
    "sass-loader": "^10.0.1",

2.如果你是Node14版本的话,可以参考以下修改方案,打开项目的package.json文件,找到node-sass和sass-loader

  1.  
    "node-sass": "^4.13.1",
  2.  
    "sass-loader": "^8.0.2",

以Node16为例:

学新通

 3.都修改好以后,重新npm install即可!如果对您有帮助的话麻烦给博客点个赞!谢谢!

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgaghhb
系列文章
更多 icon
同类精品
更多 icon
继续加载