Skip to content

Instantly share code, notes, and snippets.

@SriVinayA
Created June 17, 2019 16:41
Show Gist options
  • Save SriVinayA/56335800e19a508c97bfa4f980a870cf to your computer and use it in GitHub Desktop.
Save SriVinayA/56335800e19a508c97bfa4f980a870cf to your computer and use it in GitHub Desktop.
Install vue-cli on Linux Systems

Install vue-cli on Linux Systems

The purpose of this Gist is to show how to install the vue-cli tool, as well as its dependencies, on Linux-based systems. I am using an Ubuntu 17.10, if you want to know the version of your Ubuntu, run the following statement in the terminal:

lsb_release -a

Introduction

** vue-cli ** is a powerful command-line tool to help you create * Vue.js * projects. Vue-cli allows you to create templates for various workflows, in a few minutes, we can have an application running with several predefined tasks, with live-reload and linter.

The prerequisites for having vue-cli are:

  • Node
  • NPM (Node Package Manager)

If you already have the node and npm installed on your machine, you can skip to the topic *** Installing the vue-clie ***.

** The big problem ** is that, in Debian-based distributions, when we install the node using the version available in the official repository using * apt-get *, it will install *** node *** as ** * nodejs ***, although it sounds like bullshit, a simple nomenclature can break everything.

My recommendation is to install *** NVM *** (Node Version Manager), a script that manages different versions of Node.js. The cool thing about NVM is that we can have more than one installed version of the node on our machine and change between them.


Installing Node and NPM through NVM

To install NVM you need some dependency packages that are already in the repository of your Debin Based distribution. To do this, run the following commands:

sudo apt-get update
sudo apt-get install build-essential libssl-dev

After performing the previous step, you already have what is necessary on your system to install NVM. To do this, perform the following step:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash

Inside the URL, notice the snippet *** v0.33.2 ***, this is the version number I am using, and it may change over time, so I recommend you access the following project page in GitHub and search by the new version:

https://github.com/creationix/nvm#installation

After performing the previous step, what is being done is the download of a script and the execution of it, everything will be installed in a hidden directory in your user's folder, for this command it is not necessary to use sudo.

After the NVM installation command, it is necessary to close the terminal and open it again, since the terminal (bash) needs to process the changes. If you do not want to close, you can still run the following command:

source ~ / .profile

To verify that NVM was installed correctly, run the following command:

nvm --version

If so, bash gives a command not found error, run the following command:

command -v nvm

And again, close the terminal and open it again. When NVM is properly installed and bash the nvm command, run:

nvm ls-remote

It will display you various versions of the Node. I chose the latest LTS version, by the time I'm writing this * Gist *, it's v8.9.1. You can install it by typing:

nvm install v8.9.1

If you install more than one version and in the future you need to switch between them use the command:

nvm use - version number -

Now let's check the Node version to make sure everything has been installed correctly using the command:

node -v

With the installation of the node, we won the NPM bonus. Even so, I always like to see if there is an update to NPM and install it, in this case run the following command:

npm i npm -g

The * "problem" * is that every time you turn on your machine, it will be necessary to set the version of the Node you want to use. To work around this problem, it is possible to set a default version of the system, thus avoid having to use the *** nvm use *** command at all times.

To set a version of the node as default, run the following command:

nvm alias default - version number -

Example:

nvm alias default 8.9.1

Okay, now your environment is ready for the installation of the vue-cli.


Installing the vue-cli

Now everything has become easier, to install the vue-cli just run the following command:

npm install -g vue-cli

** Note: **

  • You may need administrator permission (the use of ** sudo **), as it is a global package.
  • In my case, because I was using NVM, administrator permission was not required.

To verify that vue-cli is properly installed, run the following command:

vue --version

If you want to see all the templates that vue-cli has, just run the following command: vue list

To create a new project with vue-cli, just enter the following:

vue init template project-name-

Example: vue init simple example-basic-vue-simple

As it will generate a package.json for you, it will have to ask you some questions, the first is what the project name will be, by default it brings the name of the folder that was defined in the previous command and then it asks what is the author of this project, that it will bring by default the name and email set globally in Git.

Like, give a Star: star:

: heart :: heart :: heart:


Follow me on social networks:

[@sigaocaue] (https://www.instagram.com/sigaocaue/)
[Cauê Prado] (https://www.facebook.com/caue.mprado)

Credits

I leave my credits to this text of Medium, who collaborated for this step-by-step: https://medium.com/collabcode/as-install-node-js-no-linux-corretamente-ubuntu-debian-elementary-os -729fb4c92f2d

@AllanMwaura22
Copy link

Thanks a lot.

@Marthely90
Copy link

Thanks!

@igorroncevic
Copy link

Thanks!

@dhiashalabi
Copy link

I had a problem while installing vue cli in ubuntu 20!

@BiKodes
Copy link

BiKodes commented Jan 30, 2021

Danke schön

@Adamskoullos
Copy link

Thank you so much for laying it out so well

@TrinhBac
Copy link

TrinhBac commented May 8, 2021

Thanks, I have just followed and installed it on Ubuntu v20.04 .

@halqupati
Copy link

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment