I'm new in vue, and a documentation says that every time I create a component I have to run npm run dev
and npm run watch
.
But don't know what their purpose is?
Can someone help me?
npm run watch always keeps running. It will watch your files for changes. So if you for example make a change in resources/assets/js/app. js and save the file, it will compile again.
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.
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.
An npm script is a convenient way to bundle common shell commands for your project. They are typically commands, or a string of commands, which would normally be entered at the command line in order to do something with your application. Scripts are stored in a project's package.
npm run dev
combines all your Vue components and other JavaScript files into a browser-friendly combined file.
npm run watch
does the same, but then it stays active and "watches" for updates to your .vue
and .js
files. If it detects a change, it'll re-build the browser-friendly file so you can just refresh the page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With