Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between" npm run serve" and "npm run dev" in vuejs

What is the difference between npm run serve and npm run dev in vuejs. Why should i use npm run serve command to run the project

like image 501
Codey Avatar asked Mar 18 '19 12:03

Codey


People also ask

What is the difference between npm run dev and npm run serve?

npm run serve is basically asking the package manager (npm) to run the command specified under the name serve in the package. json file. The same goes for the npm run dev command. It is possible that both execute the same command or different things.

What does npm run dev mean?

The npm run dev command is a generic npm command that you can find in many modern web application projects. This command is used to run the dev script defined in the project's package. json file.

What does npm serve do?

serve is a NPM package that converts our current working directory into an virtual directory i.e. the directory is hosted under localhost.

What is npm Run command?

npm run sets the NODE environment variable to the node executable with which npm is executed. If you try to run a script without having a node_modules directory and it fails, you will be given a warning to run npm install , just in case you've forgotten.


1 Answers

npm run serve basically is just saying "npm please run the command I defined under the name serve in package.json" the same happens with npm run dev.

Given this the commands can do the exact same thing, similar things, or very different things. Usually they are a shorthand for running a dev server on localhost, but it’s not a rule, only a convention.

So you'll need to check in your package.json file and look for

"scripts": {     "serve": "[list of commands here]",     "dev": "[list of commands here]" }, 
like image 82
muka.gergely Avatar answered Oct 05 '22 06:10

muka.gergely