7

前端开发:npm run serve 和 npm run dev 的区别

 3 years ago
source link: https://www.techug.com/post/front-end-development-the-difference-between-npm-run-serve-and-npm-run-dev.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

前端开发过程中运行 Vue 项目的时候,有时候使用 npm run serve 命令可以启动项目,有时候却会报错;有时候使用 npm run dev 命令可以启动项目,有时候却也会报错。是什么原因造成这种情况呢?原因在于 Vue 脚手架版本的问题,也可以理解为执行配置的脚本问题。

有的脚手架版本支持 npm run serve 命令启动项目,有的脚手架版本却支持 npm run dev 命令启动项目。那么本篇博文就来分享一下怎么避免由于脚手架版本不同造成的启动项目时候的报错问题。

先来分享一个运行 npm run serve 命令启动项目不成功,报错如下:

根据 scripts 里面是 serve 还是 dev 来启动项目:

因此,在运行 Vue 项目的时候,npm run serve 和 npm run dev 的区别就在于 vue-cli 脚手架的版本,具体情况还是要根据项目的实际情况来处理。

以上就是本章全部内容,欢迎关注三掌柜的微信公众号“程序猿 by 三掌柜”,三掌柜的新浪微博“三掌柜 666”,欢迎关注!

三掌柜的微信公众号:

本文文字及图片出自 InfoQ


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK