安装vue-router及node Sass版本过高不兼容导致报错
最近在学习vue框架的时候,遇到了几个错误:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: vue_cli_app@0.1.0
npm ERR! Found: less@4.1.2
npm ERR! node_modules/less
npm ERR! less@"^4.1.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! node_modules/less-loader
npm ERR! less-loader@"^5.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See E:\nodeJs\NodeJs\node_cache\eresolve-report.txt for a full report.
出现此问题的原因是:vue-router的版本太高了
执行该命令即可下载低版本的vue-router:
npm install vue-router@3.1.3 --save-dev --legacy-peer-deps
然后顺带解决我在启动项目的时候报的错误:
TypeError: this.getOptions is not a function at Objec
于是翻阅资料发现是node Sass版本过高于node.js 不兼容的问题
解决方案:
1.首先找到package.json下的 "sass-loader": "^7.3.1"
此处我已经下载好了可兼容的(本来是@9.XX)
2.然后在终端先卸载旧版本:
npm uninstall node-sass
3.然后安装sass
npm install sass@1.26.5 --save-dev
4.安装@7.3.1版本Sass
npm install sass-loader@7.3.1
5.重新编译安装
npm install
6.运行项目!
npm run dev
即可发现该问题已经解决!