在Windows环境下启动VUEJS报错,大致错误如下:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: webpack@5.11.1
npm ERR! node_modules/webpack
npm ERR! dev webpack@"4.41.5" from the root project
npm ERR! peer webpack@">=2" from babel-loader@8.2.2
npm ERR! node_modules/babel-loader
npm ERR! dev babel-loader@"^8.0.0" from the root project
npm ERR! 2 more (copy-webpack-plugin, css-loader)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! dev mini-css-extract-plugin@"^0.9.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: webpack@4.44.2
npm ERR! node_modules/webpack
npm ERR! peer webpack@"^4.4.0" from mini-css-extract-plugin@0.9.0
npm ERR! node_modules/mini-css-extract-plugin
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到6版本
或
使用npx指定npm的版本
npx -p npm@6 npm i --legacy-peer-deps
Windows下启动vue项目
Windows下,打开DOS窗台,替换到VUE项目的根目录下,在其终端下运行如下命令:
npm install
npm run serve 或 npm run dev
出现类似下面的界面,则表示成功