Using Vue in Visual Studio Code
Vue.js is a popular JavaScript library for building web application user interfaces and Visual Studio Code has built-in support for the Vue.js building blocks of HTML, CSS, and JavaScript. For a richer Vue.js development environment, you can install the Volar and Volar for TypeScript extensions that support Vue.js IntelliSense, code snippets, formatting, and more.
Note: Vue 2 support will end on December 31st, 2023 so the use of the Vetur extension is not recommended. You will need to disable Vetur to use Volar.
Welcome to Vue
We'll be using the Vite tooling for this tutorial. If you are new to the Vue.js framework, you can find great documentation and tutorials on the vuejs.org website.
To install and use Vite and Vue.js, you'll need the Node.js JavaScript runtime and npm (the Node.js package manager) installed. npm is included with Node.js, which you can install from Node.js downloads.
Tip: To test that you have Node.js and npm correctly installed on your machine, you can type
node --version
andnpm --version
.
To get started, make sure you are in the parent directory where you intend to create a project. Then open your terminal or command prompt and type:
npm create vue@latest
You will be prompted to install create-vue
.
This may take a few minutes to install and execute create-vue, which helps you to scaffold your Vue project. Follow the prompts for optional features. You can choose "No" if you are unsure about an option.
Once the project is created, navigate into it and install dependencies. It may take a few minutes to install its dependencies.
cd <your-project-name>
npm install
Let's quickly run our Vue application by typing npm run dev
to start the web server and open the application in a browser:
npm run dev
You should see "Welcome to your Vue.js App" on http://localhost:5173 in your browser. You can press Ctrl+C
to stop the vue-cli-service
server.
To open your Vue application in VS Code, from a terminal (or command prompt), navigate to the vue-project
folder and type code .
:
cd vue-project
code .