当拿到vue项目的时候发现运行不了的解决方案
作者:T心若孤城T
一、首先确定是否安装node_moduels
运行npm run serve 提示
> vue-automation@0.1.0 serve > vue-cli-service serve 'vue-cli-service' 不是内部或外部命令,也不是可运行的程序 或批处理文件。
这个时候就需要安装 node_moduels 命令 npm install
二、发现运行npm install报错
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: vue-automation@0.1.0
npm ERR! Found: eslint@7.26.0
npm ERR! node_modules/eslint
npm ERR! dev eslint@"^7.12.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer eslint@">= 1.6.0 < 7.0.0" from @vue/cli-plugin-eslint@4.5.13
npm ERR! node_modules/@vue/cli-plugin-eslint
npm ERR! dev @vue/cli-plugin-eslint@"^4.5.8" 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.
npm ERR!
npm ERR! See F:\Program Files\nodejs\node_cache\eresolve-report.txt for a full report.npm ERR! A complete log of this run can be found in:
npm ERR! F:\Program Files\nodejs\node_cache\_logs\2022-07-26T08_00_34_374Z-debug-0.log
这代表npm node版本不匹配,需要降版本
原因
npm 版本问题, 当前 npm 版本 7.18.1, 查阅资料后说是因为 npm7.x 的版本比 npm6.x 更严格
解决
运行
npm i --legacy-peer-deps
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
