To install Vue.js using npm (Node Package Manager), you need to have Node.js installed on your machine. Here are the steps to install Vue.js:
Install Node.js: Make sure you have Node.js installed. You can download it from the official website: Node.js.
Open a Terminal or Command Prompt:
Open your terminal or command prompt. You can find it in your operating system's applications or use the keyboard shortcut (Ctrl + Alt + T
on Linux/Ubuntu, Cmd + Space
and type "Terminal" on macOS, or Win + R
, then type "cmd" and press Enter on Windows).
Install Vue CLI (Command Line Interface): Use the following npm command to install the Vue CLI globally on your system:
bashnpm install -g @vue/cli
The -g
flag installs the package globally, so you can use the vue
command anywhere in your terminal.
Check Vue CLI Installation: After the installation is complete, you can check the installed version by running:
bashvue --version
This should display the version number of the installed Vue CLI.
Create a New Vue Project: To create a new Vue.js project, navigate to the directory where you want to create your project and run:
bashvue create my-vue-app
Replace "my-vue-app" with the name you want for your project.
Navigate to the Project Directory: Change into the project directory:
bashcd my-vue-app
Run the Development Server: Finally, you can run the development server to preview your Vue.js application:
bashnpm run serve
This will start a development server, and you can access your Vue.js application at http://localhost:8080
in your web browser.
That's it! You have successfully installed Vue.js and created a new Vue project using the Vue CLI.