1.进入前端项目安装的文件夹
输入cmd
2.在命令行中输入:npm install
3.在命令行中输入:npm run build
4.在命令行中输入:npm run serve
如果出现bug怎么办?
一、 出现以上bug
先执行下面的代码,随后再次尝试即可:
npm install rxjs
二、出现其他bug:
1.没有安装node.js(直接去百度安装,可以去哔哩哔哩看安装教程)。如何查看是否安装了node,在命令行中输入:node -v
2.查看npm版本(安装node.js就会安装npm),在命令行中输入:npm -v
3. 查看是否安装了vue脚手架(在项目路径下输入指令),查看vue脚手架版本:vue -V,没有就输入指令:npm install -g @vue/cli
4.输入npm run serve报错。
我的解决办法:把项目拖入vs code中,看package.json中的配置,我的是vue3,所以是使用npm run serve,如果是vue2,可以试试npm run dev。
5.如果上面问题都解决了(将前端项目重新获取一份,之前操作出错的删除,然后对新获取进行操作),再重新输入
npm install
npm run build
npm run serve(npm run dev)
三、npm install后出现以下错误
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: vuecli3@0.1.0
npm ERR! Found: vue@2.7.5
npm ERR! node_modules/vue
npm ERR! vue@"^2.6.10" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"^3.0.0" from vant@3.5.2
npm ERR! node_modules/vant
npm ERR! vant@"*" from the root project
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 C:\Users\l\AppData\Local\npm-cache\eresolve-report.txt for a full report.
在安装组件的时候出现以上问题,npm版本问题报错
解决方法:
在命令后面加上
--legacy-peer-deps