Command not found with vue-cli

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

error message while creating a project


Add sudo before yarn when installing

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

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


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 https://cli.vuejs.org/guide/#cli-service

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 https://yarnpkg.com/en/docs/cli/run 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.