vue-cli: vue-cli-service: command not found

Version

3.0.1

Node and OS info

nvm 0.33.1 / Node v8.11.4 / Ubuntu 16.04

Steps to reproduce

npm run build fails because vue-cli-service: command not found

What is expected?

npm run build succeeds

What is actually happening?

npm run build fails because vue-cli-service: command not found


Installed globally with npm install -g @vue/cli@latest

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 70
  • Comments: 88 (8 by maintainers)

Most upvoted comments

rm -rf node_modules package-lock.json && npm install worked for me

Please provide a valid reproduction when opening an issue.

https://asciinema.org/a/spTomiYQM8FPUuPhpPucA9S9r

Cannot reproduce on macOS. Have you tried rm -rf node_modules and npm install again?

Yeah, don’t close this issue please. I’m getting this as well. vue-cli-service: not found

I had a similar situation with Ubuntu 18.04

To fix this situation, I had to add the following line to my .zshrc (maybe in your case is .bashrc) export PATH="$(yarn global bin):$PATH"

Effectively, the yarn global bin is a folder where vue (vue cli 3) was placed

This was a suggestion from a yarn issue

@sodatea please explain how it would be possible to provide a reproduction for this issue.

If you look at https://cli.vuejs.org/guide/cli-service.html it tells you that after installing @vue/cli-service ( which may be part of the standard CLI installation ) then vue-cli-service is available in npm scripts, but that if you want to access it directly then you need to use ./node_modules/.bin/vue-cli-service This worked for me, and I guess you could add ./node_modules/.bin to your $PATH if you were so inclined.

This works fine on my macOS. The issue is on Ubuntu 16.04 with nvm.

Yes, I have tried rm -rf node_modules and reinstall.

I had an issue when I had NODE_ENV set to production, which was, quite for sure, incorrect for this script to execute. Changed back to development, and everything is fine again.

This is most likely an npm issue (for not prepending ./node_modules/.bin to $PATH). So please also try updating npm version.

Also, try to call it by npx:

npx vue-cli-service build 

Tried all the options above nothing worked for me

Like, the project repository created by vue create.

Hey! This is the correct solution: you need to install @vue/cli-service module. Using NPM

$ npm i -S @vue/cli-service

Using Yarn

$ yarn add @vue/cli-service

My solution on Ubuntu 20.04:

npm i -g @vue/cli rm -rf node_modules package-lock.json && npm install

If you use NPM package manager you need move dependencies in package.json from “devDependencies” to “dependencies”. Then NPM on Heroku will install them and vue-cli-service can build your app.

A potentiel issue of this could be that the production build gets heavier because of the additional dependency, which should not be needed in a production, especially if users want to install the app as a PWA. I could fix this on Heroku by using the heroku build hooks as explained here

"heroku-prebuild": "npm install -g @vue/cli-service",

You can also customize the heroku-postbuild if you need additional configuration.

rm -rf node_modules package-lock.json && npm install worked for me

this works for me

if happened while building docker image, try to remove NODE_ENV=production before npm install or yarn install.

I did npm install and that was enough for me.

I got it working with npx vue-cli-service ...

Had similar issues as above and this worked sudo npm cache clean -f

This fixed the issue for me:

image

Terminal Command:

./node_modules/.bin/vue-cli-service serve

If you use NPM package manager you need move dependencies in package.json from “devDependencies” to “dependencies”. Then NPM on Heroku will install them and vue-cli-service can build your app.

Of course the last comment is the one that holds the answer for me. Resolved by prepending my command with ./node_modules/.bin/

Using npm

Install globally: npm install -g @vue/cli-service-global

Add the directory where npm install globals to PATH and make it persistent in a new terminal by adding it to ~/.bashrc: echo $'\nexport PATH="$(npm -g bin)":$PATH' >> ~/.bashrc

npm cache clean -f worked for me thanks!

Hi,

I have exactly the same error for gitlab-ci:

yarn run v1.12.3 $ vue-cli-service build /bin/sh: 1: vue-cli-service: not found info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. error Command failed with exit code 127. ERROR: Job failed: exit code 1

Hi, 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.

Hey! This is the correct solution: you need to install @vue/cli-service module. Using NPM

$ npm i -S @vue/cli-service

Using Yarn

$ yarn add @vue/cli-service

Its Worked for me. If it doesent work, do this again, and call it like this ./node_modules/.bin/vue-cli-service

same issue here on ubuntu 18.04… i just tried a complete reinstall of nodejs and npm and deleted all global node_modules

Using github actions, the only way that worked for me was to set NODE_ENV to development just for install

- run: |
    NODE_ENV=development npm ci
    npm run build

My problem was in Netlify build.
By using YARN_VERSION set to 1.17.0 in environment variables of Netlify, the problem fixed.

npm install -g @vue/cli-service-global

This is the another correct way… Always works for me.

that fixs me: edit package.json -> scripts, change vue-cli-service to node_modules/.bin/vue-cli-service

on ubuntu I fixed this by:

  1. uninstalled my old npm that was installed using apt install apt-get remove npm
  2. installed nvm curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.9/install.sh | bash
  3. restarted terminal
  4. installed latest npm using nvm nvm install --latest-npm
  5. reinstall packages as suggested by diachedelic rm -rf node_modules package-lock.json && npm install

Tried all of the suggestions above and still having this issue with OS X 10.14.2. vue --version displays 3.3.0.

Another solution

If you use yarn:

  1. Install the vue cli globally if you didn’t already:
yarn global add @vue/cli
  1. Get the path where yarn stores global packages and copy the output:
yarn -g bin

// Output: /home/YOUR_USER_NAME/.yarn/bin
  1. Open file ~/.bashrc for editing in any text editor on directly in terminal using nano:
sudo nano ~/.bashrc
  1. Add the following line somewhere after the initial comments in that file. And replace THE_OUTPUT_FROM_STEP_2 with the text that you copied in step 2 :
export PATH=$PATH:THE_OUTPUT_FROM_STEP_2

This will add the .yarn/bin directory to $PATH and will make it possible to use every package located in this directory globally.

  1. Save with Ctrl + S and exit Ctrl + X

  2. Log out / Log in (or restart the computer)

  3. Done. Now you can call vue globally, e.g. to check vue version run:

vue --version
  1. If it still cannot find vue, go back to step 3 and in step 4, instead of the yarn -g bin output, specify the following path:
export PATH=$PATH:/home/YOUR_USER_NAME/.yarn/bin

Don’t forget to replace YOUR_USER_NAME with your username

If you use npm:

Do the same thing but:

  • In the step 1 run npm install -g @vue/cli instead of yarn global add @vue/cli
  • In the step 2 run npm -g bin instead of yarn -g bin

  • The other solutions worked for me only temporarily until the terminal window is re-opened.
  • I don’t use Linux as my primary OS, so I don’t know if it’s a good idea to add path variables to ~/.bashrc file.

Hey! This is the correct solution: you need to install @vue/cli-service module. Using NPM

$ npm i -S @vue/cli-service

Using Yarn

$ yarn add @vue/cli-service

it’s work for me too

Local build is fine. It is not built on Docker and Travis. What’s wrong?

# base image
FROM node:11.12.0-alpine as builder
ENV PATH ./node_modules/.bin:$PATH

RUN apk update && apk --no-cache --virtual build-dependencies add python make g++ \
    && npm install \
    && apk del build-dependencies
RUN npm run build
  • Result
sh: vue-cli-service: not found
  • My package.json file
{
  "private": true,
  "scripts": {
    "serve": "./node_modules/.bin/vue-cli-service serve --modern",
    "build": "./node_modules/.bin/vue-cli-service build --modern"
  },
"dependencies": {
    "@mdi/font": "^4.7.95",
    "core-js": "^3.4.4",
    "vue": "^2.6.10",
    "vue-i18n": "^8.0.0",
    "vue-router": "^3.1.3",
    "vuejs-logger": "^1.5.3",
    "vuetify": "^2.1.0",
    "vuex": "^3.1.2"
  },
  "devDependencies": {
    "@kazupon/vue-i18n-loader": "^0.3.0",
    "@vue/cli-plugin-babel": "^4.1.0",
    "@vue/cli-plugin-eslint": "^4.1.0",
    "@vue/cli-plugin-router": "^4.1.0",
    "@vue/cli-plugin-unit-jest": "^4.1.0",
    "@vue/cli-plugin-vuex": "^4.1.0",
    "@vue/cli-service": "^4.1.0",
    "@vue/eslint-config-standard": "^4.0.0",
    "@vue/test-utils": "1.0.0-beta.29",
    "babel-eslint": "^10.0.3",
    "eslint": "^5.16.0",
    "eslint-plugin-vue": "^5.0.0",
    "jest-coverage-badges": "^1.1.2",
    "node-sass": "^4.12.0",
    "prerender-spa-plugin": "^3.4.0",
    "robotstxt-webpack-plugin": "^7.0.0",
    "sass": "^1.19.0",
    "sass-loader": "^8.0.0",
    "standard-version": "^7.0.1",
    "vue-cli-plugin-vuetify": "^2.0.3",
    "vue-template-compiler": "^2.6.10",
    "vuetify-loader": "^1.3.0"
  }
}

i can’t understand

Thanks @yoannes - I was missing the npm ci as part of my build.

- run: npm ci && npm run build

worked for me

In my case, the package @vue/cli-service is installed in my local node_modules environment, but not my global environment, so it cannot be used as a command. I type ./node_modules/.bin/vue-cli-service serve and it works.

Not sure if this is the correct solution, but deleting node_modules and npm install didn’t solve it for me. It looks like you need to install @vue/cli-service and any plugins you use globally. Here’s my solution: Host: Windows 10

Dockerfile

FROM node:8.10-stretch

# update npm & install vue cli peer dependencies
RUN npm install -g npm
RUN npm install -g @vue/cli @vue/cli-service @vue/cli-plugin-babel @vue/cli-plugin-eslint

WORKDIR /app

COPY package*.json ./
RUN npm ci

VOLUME /app

CMD npm run serve

docker-compose.yml

version: "3.5"

services:
  ui:
    build:
      context: ui/
    ports:
      - 3000:80
    volumes:
      - ./ui/:/app
      - shadow-ui:/app/node_modules:delegated # see comment below
    stdin_open: true
    tty: true
    environment:
      CHOKIDAR_USEPOLLING: 'true'

volumes:
  shadow-ui: # see comment below

The shadow-ui volume prevents the node_modules directory on my host (windows) from being mounted into my container (debian), so npm ci will download the correct binaries for node-sass. This error presents itself as “Could not find package vue-template-compiler” or something similar.

This fixed the issue for me:

image

Terminal Command:

./node_modules/.bin/vue-cli-service serve

finally this helped me, thank a lot.

I had an issue when I had NODE_ENV set to production, which was, quite for sure, incorrect for this script to execute. Changed back to development, and everything is fine again.

https://github.com/vuejs/vue-cli/issues/2404#issuecomment-454642931

Yeah but then how do you deploy your actual production environment then 😄 ?

I try all of them and now it’s working)

My solution on Ubuntu 20.04:

npm i -g @vue/cli rm -rf node_modules package-lock.json && npm install

This work for me too…

Similar to @COil’s comment. Simply got this error when cloning new repo and attempting to run yarn serve before yarn/yarn install.

in my case I think there was a conflict with yarn and npm.

I did

  1. yarn remove global @vue/cli
  2. npm cache -f clean
  3. yarn add global @vue/cli

Which worked for me

rm -rf node_modules package-lock.json && npm install 为我工作

thanks

Hi, everyone, I’ve got the same error.

Apparently, I try to build the app locally, and it works fine.

But when I push the code to github, and the arrival of a new commit triggers travis-ci build job, and it gives me the error which is “/bin/sh: 1: vue-cli-service: not found”.

https://github.com/whizjs/superjs/blob/master/.travis.yml

By the way, travis-ci has been working fine util this latest commit.

I don’t know where to start the debug.