Full-Stack Web Development with Vue.js and Node

(singke) #1
Building the Real Application Chapter 5

Using Vue.js as an npm package


npm also has a package for vue, which can be installed as follows:


$ npm install vue

Introducing vue-cli


CLI stands for Command Line Interface. A cli runs one or multiple commands


successively in a command line interface. Vue.js also has a cli which, when installed,


makes it super easy to spin up a project. We will be using a vue-cli in this book to create


the Vue.js application. Let's install vue-cli with the following command. You can execute


this command in your root folder:


$ npm install -g vue-cli

Initializing projects with vue-cli


Let's go ahead with creating a new project folder for our movie rating application. We will


call it movie_rating_app. Go to the directory where you want to create your application


in the Terminal and run the following:


$ vue init webpack movie_rating_app

The preceding command initializes an application with all the dependencies that a Vue.js


project requires. It will ask you a few questions about the project setup, to which you can


answer either y, as in yes, or n, as in no:


Vue build: You will find two options to build the Vue.js app: runtime + compiler,
or runtime Only. This has to do with the template compiler:
Runtime only: The runtime option is used to create the vue
instances. This option does not include the template compiler.
Runtime + compiler: This option includes the template compiler,
which means the vue templates are compiled to the
plain JavaScript render functions.
Free download pdf