DEV Community

DEVEV
DEVEV

Posted on

Vue CLI Guide

Vue CLI Overview

Vue CLI is the easiest way to build a new Vue app.
It provides:

  • a command-line utility for you to choose build tools
  • official plugins
  • runtime dependency built on top of webpack with sensible defaults

Installation & Update

Run one of the following commands.

Vue CLI 4.x requires Node.js version 8.9 or above. Manage multiple versions of Node with nvm.

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

Check if you did it right↓

$ vue --version
Enter fullscreen mode Exit fullscreen mode

To upgrade the global Vue CLI package, run↓

$ npm update -g @vue/cli
# OR
$ yarn global upgrade --latest @vue/cli
Enter fullscreen mode Exit fullscreen mode

Creating a Project

To create a new project, run↓

$ vue create <project name>
Enter fullscreen mode Exit fullscreen mode

and you'll be prompted to pick a preset. You can either choose the default preset or select "Manually select features" to pick the versions and features you need.


Troubleshooting

Vue command not found error after installation

a. Uninstall vue/cli and install it again

(and then restarting terminal recommended)

$ npm uninstall -g @vue/cli
# OR
$ yarn global remove @vue/cli
Enter fullscreen mode Exit fullscreen mode

If the globall installation fails, try running command with prefix 'sudo'.

$ sudo npm uninstall vue-cli -g
$ sudo npm install -g @vue/cli
Enter fullscreen mode Exit fullscreen mode

b. Uninstall and install node again with the right version

check installed node version↓

$ node --verison
Enter fullscreen mode Exit fullscreen mode

How to uninstall Node.js completely

c. Add PATH environment variable

Run following command to see where npm puts your globally installed packages.

$ npm config get prefix
Enter fullscreen mode Exit fullscreen mode
# output example(windows)
# C:\Users\{UserName}\AppData\Roaming\npm
Enter fullscreen mode Exit fullscreen mode

Check if your operating system has the PATH environment variable. If not, add the path you got from the command above.

How to add PATH environment variable on WINDOWS

Open command promt(windows key + R) and run command↓

$ set
Enter fullscreen mode Exit fullscreen mode

It will show you PATHs added to your OS. Try update it on Windows Control Panel.

Control Panel > System and Security > System > Advanced system settings > Environment Variables...


Sources

https://cli.vuejs.org/
https://bobbyhadz.com/blog/npm-command-not-found-vue

Top comments (0)