关键报错信息
npm ERR! gyp verb check python checking for Python executable "python2.7" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2.7
或者
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: sass-loader@8.0.2
npm ERR! Found: node-sass@6.0.1
npm ERR! node_modules/node-sass
npm ERR! dev node-sass@"^6.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional node-sass@"^4.0.0" from sass-loader@8.0.2
npm ERR! node_modules/sass-loader
npm ERR! dev sass-loader@"^8.0.2" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: node-sass@4.14.1
npm ERR! node_modules/node-sass
npm ERR! peerOptional node-sass@"^4.0.0" from sass-loader@8.0.2
npm ERR! node_modules/sass-loader
npm ERR! dev sass-loader@"^8.0.2" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
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
"node-sass": "^6.0.1",
"sass-loader": "^10.0.1",
2.如果你是Node14版本的话,可以参考以下修改方案,打开项目的package.json文件,找到node-sass和sass-loader
"node-sass": "^4.13.1",
"sass-loader": "^8.0.2",
以Node16为例:
3.都修改好以后,重新npm install即可!如果对您有帮助的话麻烦给博客点个赞!谢谢!