{"id":3267,"date":"2020-12-30T23:49:56","date_gmt":"2020-12-31T04:49:56","guid":{"rendered":"http:\/\/bluegalaxy.info\/codewalk\/?p=3267"},"modified":"2020-12-30T23:49:58","modified_gmt":"2020-12-31T04:49:58","slug":"vue-js-how-to-use-vue-cli-to-quickly-create-a-project","status":"publish","type":"post","link":"https:\/\/bluegalaxy.info\/codewalk\/2020\/12\/30\/vue-js-how-to-use-vue-cli-to-quickly-create-a-project\/","title":{"rendered":"Vue.js: How to use Vue CLI to quickly create a project"},"content":{"rendered":"\n<p>Vue.js comes with a built in command line tool called <code>Vue CLI<\/code>, which makes setting up a new Vue.js project a breeze. Vue.js can be used without this, but the advantage of using <code>Vue CLI<\/code> is that it sets up a Vue.js project using Babel and Webpack and allows the project to be launched easily in a web browser via an npm command. <\/p>\n\n\n\n<p>Before running the VUE CLI command, we need to make sure we have NPM installed on our machine first. This can be done with the command <\/p>\n\n\n\n<p><code>npm -v<\/code><\/p>\n\n\n\n<p>For example:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized is-style-default\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-2.png\" alt=\"\" class=\"wp-image-3274\" width=\"372\" height=\"142\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-2.png 580w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-2-300x114.png 300w\" sizes=\"auto, (max-width: 372px) 100vw, 372px\" \/><\/figure>\n\n\n\n<p>Now that we confirmed we have npm already installed, we next need to install VUE CLI from a command prompt. At the command prompt, use the command <\/p>\n\n\n\n<p><code>npm install -g @vue\/cli<\/code>. <\/p>\n\n\n\n<p>If there are errors related to JSON, check the folder location for existing package.json or package-lock.json files. These should be removed OR try running the command in a different folder. Note: you can ignore all of the deprecated messages and there is no need to independently install the deprecated modules. <\/p>\n\n\n\n<p>Here is what the output in the command prompt may look like.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"717\" src=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-3-1024x717.png\" alt=\"\" class=\"wp-image-3282\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-3-1024x717.png 1024w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-3-300x210.png 300w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-3-768x537.png 768w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-3-1536x1075.png 1536w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-3-676x473.png 676w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-3.png 1822w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Once this step is complete, you can check the version of Vue.js with this command: <code>vue --version<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized is-style-default\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-4.png\" alt=\"\" class=\"wp-image-3284\" width=\"221\" height=\"71\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-4.png 329w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-4-300x97.png 300w\" sizes=\"auto, (max-width: 221px) 100vw, 221px\" \/><\/figure>\n\n\n\n<p> Now that we know Vue CLI is installed, we can easily create a new Vue.js project at the command line. For example, let&#8217;s say we wanted to create a new project called &#8220;video-browser&#8221;. cd to the folder you want to create this project in and run the command <code>vue create -n video-browser<\/code><\/p>\n\n\n\n<p>The <code>-n<\/code> here means start the project without git. Here is what the output looks like:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized is-style-default\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-5-668x1024.png\" alt=\"\" class=\"wp-image-3286\" width=\"520\" height=\"797\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-5-668x1024.png 668w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-5-196x300.png 196w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-5-768x1177.png 768w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-5-652x999.png 652w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-5.png 909w\" sizes=\"auto, (max-width: 520px) 100vw, 520px\" \/><\/figure>\n\n\n\n<p>You should see the text that says &#8220;Successfully created project video-browser.<\/p>\n\n\n\n<p>Next cd into that new folder. Then run the command <code>npm run serve<\/code> and this will launch a web service where you can see some default output for your new web project. For example:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized is-style-default\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-6.png\" alt=\"\" class=\"wp-image-3287\" width=\"369\" height=\"299\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-6.png 638w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-6-300x244.png 300w\" sizes=\"auto, (max-width: 369px) 100vw, 369px\" \/><\/figure>\n\n\n\n<p>As can be seen in the message, we can now view the default web page for our new Vue.js app in the browser at this location: http:\/\/localhost:8080<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized is-style-default\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-7-887x1024.png\" alt=\"\" class=\"wp-image-3288\" width=\"535\" height=\"617\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-7-887x1024.png 887w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-7-260x300.png 260w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-7-768x886.png 768w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-7-676x780.png 676w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-7.png 960w\" sizes=\"auto, (max-width: 535px) 100vw, 535px\" \/><\/figure>\n\n\n\n<p>Now that the video-browser folder has been created, you can open it as a project in Atom or your favorite IDE. Notice all of the files and folder structure created for free. For example:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized is-style-default\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-8-1024x993.png\" alt=\"\" class=\"wp-image-3291\" width=\"768\" height=\"745\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-8-1024x993.png 1024w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-8-300x291.png 300w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-8-768x745.png 768w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-8-676x656.png 676w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/12\/image-8.png 1433w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Vue.js comes with a built in command line tool called Vue CLI, which makes setting up a new Vue.js project a breeze. Vue.js can be used without this, but the advantage of using Vue CLI is that it sets up a Vue.js project using Babel and Webpack and allows the project to be launched easily &hellip; <a href=\"https:\/\/bluegalaxy.info\/codewalk\/2020\/12\/30\/vue-js-how-to-use-vue-cli-to-quickly-create-a-project\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Vue.js: How to use Vue CLI to quickly create a project<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[221],"tags":[91,222,61],"class_list":["post-3267","post","type-post","status-publish","format-standard","hentry","category-vue-js","tag-npm","tag-vue-cli","tag-vue-js"],"_links":{"self":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts\/3267","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/comments?post=3267"}],"version-history":[{"count":16,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts\/3267\/revisions"}],"predecessor-version":[{"id":3293,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts\/3267\/revisions\/3293"}],"wp:attachment":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/media?parent=3267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/categories?post=3267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/tags?post=3267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}