How do I install vue/cli in ubuntu?
You are trying to install a npm
package globally and npm
stores this packages inside /usr/local/lib
folders. Your user
does not have permission to edit files outside of the home
directory for security reason.
Option 1 - Stop using npm
and start using yarn
The issue is connected to npm
so I would stop using it and install yarn
as in their official guide. Packages should be stored inside your home
directory, even when installed globally like the other package manager do (Yarn
, rbenv
etc..), for this and many other reasons I would stop using npm
.
Option 2 - Try to fix npm
There are several solution proposed in this discussion, none of which really good options.
The best option is changing the permission to the folder /usr/local/lib
as explained here
sudo chown -R [owner]:[owner] /usr/local/lib
Then follow the official @vue/cli
installation instructions for either npm
or yarn
Options 3 - Install it via apt package manager
I don't suggest you to use apt package manager, as you may work with different projects which use different versions of this package. If project 1 uses @vue/cli
version 1, then you update because you want to work on project 2, project 1 may not work anymore.
sudo npm install -g @vue/cli
Looking for various answers on the internet, I just spent an hour tearing my hair out over this issue. I managed to resolve this problem with Adams solution looking into here.
What I learned is that instead of looking for a problem all over the internet for (mostly deprecated) solutions, I should first take a close look at exactly what errors does my terminal show up and start from there.
This was my solution for using Vue CLI on Ubuntu 18.04. Thank you.