How to Install Vue.js: A Step-by-Step Guide for Beginners
Table of Content:
Vue JS can be installed in three ways:
-
Using CDN (the easiest way)
-
Using NPM and
-
Using vue-cli (the way you will be working)
Using Vue through CDN
-
As said before, using Vue through CDN is the easiest way.
-
The CDN link,
https://unpkg.com/vueallows a developer to create Vue web-page instantly. -
Using a
scripttag withsrcattribute as this link, allows one to use Vue JS functionalities.
Note: This method requires an active internet connection to work.
Installing Vue through NPM
In a system with nodejs and npm already on it, use the below steps to install Vue using NPM.
-
To verify the
nodejsandnpminstallation, run the commandsnode -vandnpm -v. -
Create a project folder and change the working directory into it.
-
To install project dependencies, package.json can be created using the command
npm init -ywith defaults for the prompts. -
To install Vue using NPM, use the command
npm install vue --save.
Installing Vue through vue-cli
In a system with node and npm already installed, install vue-cli with the below steps:
-
Install
vue-cliusing the commandnpm install -g @vue/cli. -
To create a project named using
vue-cli, use the commandvue init webpack sample. -
Choose the defaults or appropriate options for prompts.
NOTE 1: Vue requires "npm" version to be at least 6.
NOTE 2: The "webpack" used when creating a project, refers to the development environment being used with Vue.