Command Not Found with Vue-Cli

Command Not Found with Vue-Cli

While installing the dependencies of vue-cli, vue is not identified. Why?

3

23 Answers

Add sudo before yarn when installing

  • yarn global remove @vue/cli
  • sudo yarn global add @vue/cli
  • vue
5

rm -rf node_modules and npm install again have a look here

1

Installing current version without permanently installing vue-cli.

npx @vue/cli create appname 

I had the same issue for a while.

TL;DR

 npm install @vue/cli-service --save-dev

As the documentation specify it is a development dependency

The CLI Service (@vue/cli-service) is a development dependency. It's an npm package installed locally into every project created by @vue/cli.

Origin

I had a fresh install of nodejs And just did

>> sudo npm install -g @vue/cli@latest

>> vue --version
@vue/cli 4.5.8

The issue

The issue presented like this

>> npm run serve
yarn run v1.22.10
$ vue-cli-service build --mode development --watch
/bin/sh: 1: vue-cli-service: not found
error Command failed with exit code 127.
info Visit  for documentation about this command.

The fixes:

npm install @vue/cli-service --save-dev

Which led me straight to another error message

>> npm run serve
yarn run v1.22.10
$ vue-cli-service build --mode development --watch
ERROR  Error: Cannot find module 'vue-template-compiler/package.json'

Which I fixed the same way

npm i vue-template-compiler --save-dev

And now it is working fine.

It shows the vue executable is located at /home/alisha/.local/bin. So probably this location is not there in your $PATH.

You should be able to run the vue commands if you provide the full path, like:

~/.local/bin/vue create hello-world

You can also see if that directory is in your PATH by running some command like:

echo $PATH | grep '.local/bin/'

If it's there, you would see it, otherwise you can add it to your path by placing it in your ~/.profile.

Edit ~/.profile and add the following at the bottom of it.

PATH="$HOME/.local/bin:$PATH"

Hope it helps!!

3

I had the same issue while making a build for production.

You will require vue-cli to be installed. Use below command to install the latest version.

npm install -g @vue/cli@latest

Then

npm install
1

THIS FIXED THE ISSUE FOR ME:

After running

sudo npm install -g @vue/cli

I ran

sudo nano $HOME/.profile

and pasted the following line

export PATH=$PATH:/home/chike/.npm-global/bin

after writing the code, next thing I did was Ctrl + O, ENTER and Ctrl + X then wrote

vue init webpack myapp

Might have to do with you having an old version on your computer:

Warning regarding Previous Versions

The package name changed from vue-cli to @vue/cli. If you have the previous vue-cli (1.x or 2.x) package installed globally, you need to uninstall it first with npm uninstall vue-cli -g or yarn global remove vue-cli.

You can find it here:

When you install vue using cli that time you got the path of vue.Now you can copy the bin folder path.
In my example /home/sublime/.npm-packages/bin

Now you export the path below command

export PATH=$PATH:/home/sublime/.npm-packages/bin

I solved mine by running (add sudo if needed)

  • npm i -g vue-cli@2.9.6
  • npm i -g @vue/cli
1

Got similar issue when deploy vue project in jenkins.

Here is what I did:

Add node's bin/ dir, to jenkins user's .bashrc file.

e.g

# node
NODE_HOME=/home/dev/.nvm/versions/node/default
PATH=$NODE_HOME/bin:$PATH

Marcus Vance
Author

Marcus Vance

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.