Bird
Raised Fist0
Vueframework~20 mins

Creating a new Vue project - Practice Exercises

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Vue Project Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2:00remaining
What is the correct command to create a new Vue 3 project using the official CLI?
You want to start a new Vue 3 project using the Vue CLI. Which command will correctly create the project?
Anpm create vue@latest my-vue-app
Bvue create my-vue-app
Cvue init my-vue-app
Dnpm install vue create my-vue-app
Attempts:
2 left
💡 Hint
The latest Vue CLI uses npm create with the vue@latest package.
❓ component_behavior
intermediate
2:00remaining
What will be the rendered output of the default App.vue in a new Vue 3 project?
After creating a new Vue 3 project, the default App.vue contains a template with a <h1> tag showing "Welcome to Your Vue.js App". What will you see in the browser when you run the project?
Vue
<template>
  <h1>Welcome to Your Vue.js App</h1>
</template>

<script setup>
// no script content
</script>

<style>
h1 {
  color: #42b983;
}
</style>
ANo heading is shown because script is empty
BA green heading that says 'Welcome to Your Vue.js App'
CA plain heading with default black color 'Welcome to Your Vue.js App'
DAn error because script setup is empty
Attempts:
2 left
💡 Hint
Check the style section and the template content.
❓ lifecycle
advanced
2:00remaining
When does the onMounted lifecycle hook run in a Vue 3 component?
You add an onMounted hook inside the setup() function of a Vue 3 component. When exactly does this hook execute?
AAfter the component is mounted to the DOM and visible
BRight after the component is created but before it is added to the DOM
CBefore the component is created
DOnly when the component is destroyed
Attempts:
2 left
💡 Hint
Think about when the component is fully ready and visible.
🔧 Debug
advanced
2:00remaining
Why does this Vue 3 component fail to update the displayed count?
Consider this Vue 3 component code:
import { ref } from 'vue';

export default {
  setup() {
    let count = 0;
    function increment() {
      count++;
    }
    return { count, increment };
  }
}
The template uses {{ count }} and a button calls increment. Why does the displayed count not update when the button is clicked?
ABecause count should be declared with const, not let
BBecause increment function is not returned from setup
CBecause count is a plain variable, not a reactive ref
DBecause the template syntax {{ count }} is invalid
Attempts:
2 left
💡 Hint
Think about Vue's reactivity system and how it tracks changes.
🧠 Conceptual
expert
3:00remaining
What is the main advantage of using Vue 3's Composition API over Options API in a new project?
You are deciding between using the Options API or the Composition API for your new Vue 3 project. What is the key benefit of the Composition API?
AIt requires less code because lifecycle hooks are not needed
BIt automatically improves app performance without code changes
CIt removes the need for templates by using only JavaScript
DIt allows better organization and reuse of logic by grouping related code together
Attempts:
2 left
💡 Hint
Think about how code is structured and reused in larger projects.

Practice

(1/5)
1. What is the correct command to start creating a new Vue project using the latest recommended method?
easy
A. npm create vue@latest
B. vue create project
C. npm install vue
D. npm run vue

Solution

  1. Step 1: Understand the official Vue project creation command

    The recommended way to create a new Vue project is using npm create vue@latest, which scaffolds the project with the latest setup.
  2. Step 2: Compare with other commands

    Other commands either install Vue or run scripts but do not create a new project scaffold.
  3. Final Answer:

    npm create vue@latest -> Option A
  4. Quick Check:

    Use npm create vue@latest to start a Vue project [OK]
Hint: Use 'npm create vue@latest' to start a new Vue project [OK]
Common Mistakes:
  • Using 'vue create' which is from older Vue CLI
  • Trying to install Vue instead of creating project
  • Running npm scripts unrelated to project creation
2. Which of the following commands correctly runs the development server after creating a Vue project?
easy
A. vue serve
B. npm start
C. npm run dev
D. npm run start

Solution

  1. Step 1: Identify the standard Vue dev server command

    After creating a Vue project, the usual command to start the development server is npm run dev.
  2. Step 2: Understand why other options are incorrect

    npm start or npm run start are common in other projects but not default in Vue. vue serve is not standard in Vue 3 projects created with the latest tool.
  3. Final Answer:

    npm run dev -> Option C
  4. Quick Check:

    Run dev server with npm run dev [OK]
Hint: Use 'npm run dev' to start Vue dev server [OK]
Common Mistakes:
  • Using 'npm start' which is not default in Vue projects
  • Trying 'vue serve' which is outdated
  • Confusing 'npm run start' with 'npm run dev'
3. After running npm create vue@latest and answering setup questions, what will happen when you run npm run dev inside the project folder?
medium
A. The Vue app compiles and opens a local server showing the default welcome page.
B. It installs Vue dependencies but does not start any server.
C. It throws an error because the project is not built yet.
D. It deletes the project files and exits.

Solution

  1. Step 1: Understand the purpose of 'npm run dev'

    This command starts the development server, compiles the Vue app, and serves it locally.
  2. Step 2: Recognize expected behavior after project setup

    After setup, running this command shows the default Vue welcome page in the browser.
  3. Final Answer:

    The Vue app compiles and opens a local server showing the default welcome page. -> Option A
  4. Quick Check:

    Dev server runs and shows app page [OK]
Hint: Run 'npm run dev' to see your Vue app live locally [OK]
Common Mistakes:
  • Expecting 'npm run dev' to only install dependencies
  • Thinking the command builds but does not serve
  • Confusing errors with missing setup steps
4. You ran npm create vue@latest but got an error saying 'command not found'. What is the most likely cause?
medium
A. You forgot to create a project folder before running the command.
B. You do not have Node.js and npm installed or they are not in your system PATH.
C. You need to run the command inside an existing Vue project folder.
D. The command requires an internet connection but you are offline.

Solution

  1. Step 1: Understand the error 'command not found'

    This error usually means the system does not recognize the command because Node.js and npm are missing or not set up properly.
  2. Step 2: Evaluate other options

    Creating a folder or internet connection issues do not cause 'command not found'. Running inside a Vue project folder is not required to create a new project.
  3. Final Answer:

    You do not have Node.js and npm installed or they are not in your system PATH. -> Option B
  4. Quick Check:

    Missing Node.js/npm causes 'command not found' [OK]
Hint: Check Node.js and npm installation if command not found error appears [OK]
Common Mistakes:
  • Assuming folder creation is required before command
  • Thinking command must run inside Vue project
  • Ignoring system PATH setup for Node.js/npm
5. You want to create a Vue project with TypeScript support and router enabled. Which step should you do during npm create vue@latest setup to achieve this?
hard
A. Edit the package.json file after creation to add TypeScript and Router dependencies.
B. Manually install TypeScript and Vue Router after project creation.
C. Run npm create vue@latest --typescript --router to auto-enable features.
D. Select TypeScript and Router options when prompted during the setup questions.

Solution

  1. Step 1: Understand the interactive setup process

    When running npm create vue@latest, it asks questions to customize your project, including enabling TypeScript and Router.
  2. Step 2: Recognize the correct way to enable features

    Selecting these options during setup automatically configures the project with needed dependencies and settings.
  3. Step 3: Evaluate other options

    Manual installs or editing files after creation are possible but not the recommended or easiest way. Command line flags such as npm create vue@latest --typescript --router are not supported.
  4. Final Answer:

    Select TypeScript and Router options when prompted during the setup questions. -> Option D
  5. Quick Check:

    Choose features during setup for easy config [OK]
Hint: Pick features during setup prompts to configure project easily [OK]
Common Mistakes:
  • Trying to add features only after project creation
  • Assuming command line flags auto-enable features
  • Editing package.json manually instead of using setup
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard