DEV Community

Cover image for How to kickstart a Vue.js project in 3 min
Andreas
Andreas

Posted on • Updated on

How to kickstart a Vue.js project in 3 min

Without losing many words I'll start straight away: This is a guide showing how to rapidly start Vue.js development with the Vue CLI. So if you wanted to try Vue.js for some time now and can relate to questions like "How to begin without much effort?" — I hope this post can make the start with Vue.js easier for you.

Setup Vue CLI

To save a lot of time, let the Vue Command-Line Interface do all the work for you. Vue CLI is simply a npm packages, that is globally installed to provide the vue command. You can install it by using npm or yarn:

npm install -g @vue/cli
# OR
yarn global add @vue/cli
Enter fullscreen mode Exit fullscreen mode

Note: Vue CLI requires Node.js version 8.9 or above

To verify the successful installation, try this:

vue --version
# 4.0.5
Enter fullscreen mode Exit fullscreen mode

Now everything's ready to setup your project.

Create a new project

Navigate to the directory where you want to start your new project in and run the following command:

vue create my-vue-app
Enter fullscreen mode Exit fullscreen mode

Note that my-vue-app is the title of your project, choose whatever title you like.

Now Vue CLI starts an interactive feature selection, let's see what we have here:

Vue CLI new project

At this point you can either choose a preset (the first two options in the screenshot above are presets I already saved earlier) or the default configuration or the manual selection of features. For now you can just navigate to default using the arrow keys and hit Enter.

The result should be similar to this:

Vue CLI process new project

Looks like Vue CLI was really busy doing things. Let's see, what it did in particular (not necessarily in that order):

  • Create a default package.json containing some dependencies for production and development
  • Install dependencies (node modules)
  • Create the project files and directories
  • Initialize a Git repository
  • Create a README.md with some basic commands to develop your project

The project file structure looks like this:

Vue Project File Structure

It is served hot

Now that you've got an overview what Vue CLI created for you, you can start a development server to see the result. Run the following:

yarn serve
Enter fullscreen mode Exit fullscreen mode

This compiles the project and serves it at localhost:8080 with hot-reload. So whenever you're changing something (e.g. adjusting the welcome message at line 4 in App.vue) you don't have to reload the page in your browser, it updates automatically.

Vue App in Browser

Now simply start playing around with Vue.js. This post is as incomplete as it is short - it was just meant to be a starting point for those struggling to begin with Vue.js. And don't forget to look into the docs, they are awesome 😎

Let me know in the comments, if you want to go more into detail at any point!


Originally published: 1st November 2019 on Medium

Top comments (5)

Collapse
 
milburngomes profile image
MilburnGomes

Great Article! I've tried it and its working perfectly fine. If you can also provide SQL database connection and API routing, it will be amazing!

Collapse
 
devmount profile image
Andreas

Thanks, I'm really glad its useful for you! Your suggestions are noted 👍🏻

Collapse
 
milburngomes profile image
MilburnGomes

👍🏻

Collapse
 
stuffbyspencer profile image
---spencer---

Nice, even though I already knew this, I still enjoyed the read, which is a good point on your writing & presentation skills!

Thanks for the writeup :)

Collapse
 
devmount profile image
Andreas

Thank you so much, I'm glad you enjoyed the read! Always good to hear as a non-native :)