vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.76k stars 6.33k forks source link

vue-cli-service: command not found #2404

Closed dimavolo closed 6 years ago

dimavolo commented 6 years ago

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

haoqunjiang commented 6 years ago

Please provide a valid reproduction when opening an issue.

dimavolo commented 6 years ago

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

haoqunjiang commented 6 years ago

Like, the project repository created by vue create.

dimavolo commented 6 years ago

Okay, here is a repository that I created with vue create:

https://github.com/DimaFromCanada/testrepoforvue.git

haoqunjiang commented 6 years ago

https://asciinema.org/a/spTomiYQM8FPUuPhpPucA9S9r

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

dimavolo commented 6 years ago

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.

haoqunjiang commented 6 years ago

Still can't reproduce with a fresh install of nvm & node. https://asciinema.org/a/hRDyrM5HcDHVieV3mPLEVlhdL

Maybe the $PATH variable is somehow messed up in your environment.

dimavolo commented 6 years ago

Please let me know what executables the $PATH should include.

Have you tested in Ubuntu 16.04? On Thu, 30 Aug 2018 at 11:47 PM Haoqun Jiang notifications@github.com wrote:

Still can't reproduce with a fresh install of nvm & node. https://asciinema.org/a/hRDyrM5HcDHVieV3mPLEVlhdL

Maybe the $PATH variable is somehow messed up in your environment.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/vuejs/vue-cli/issues/2404#issuecomment-417346214, or mute the thread https://github.com/notifications/unsubscribe-auth/AK5OkJWsFS1XqKD0gNGEUWqFB9OnB00Mks5uV_r1gaJpZM4WThwJ .

haoqunjiang commented 6 years ago

Yes, I've posted the terminal session recorded in Ubuntu 16.04 above. I don't know if this helps but here's my $PATH: /home/soda/.nvm/versions/node/v8.11.4/bin:/home/soda/bin:/home/soda/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

haoqunjiang commented 6 years ago

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 
haoqunjiang commented 6 years ago

Closing due to inactivity for more than 1 week. Please open a new issue with a reference to this one if you can follow up with more information.

jsparedes commented 6 years ago

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

patientplatypus commented 6 years ago

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

medmin commented 6 years ago

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.

elhenro commented 6 years ago

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

ddosdor commented 5 years ago

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

GiorgosK commented 5 years ago

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

diachedelic commented 5 years ago

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

sanfx commented 5 years ago

Tried all the options above nothing worked for me

PeterA1 commented 5 years ago

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.

snirp commented 5 years ago

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

medmin commented 5 years ago

I think @PeterA1 could be right.

Rozkalns commented 5 years ago

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.

lstanard commented 5 years ago

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

LanFeusT23 commented 5 years ago

npm cache clean -f worked for me thanks!

ciryon commented 5 years ago

I had the same problem when building on Bitbucket Pipelines. The solution was, similar to above, to go to pipelines, select Caches, mouseover the node_modules dependency cache and click the trashcan icon.

barsv commented 5 years ago

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

thammarith commented 5 years ago

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

zacharyyates commented 5 years ago

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.

hyuckgi commented 5 years ago

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

canonigod commented 5 years ago

sudo yarn install fixed mine thanks @hyuckgi

mmichealjroberts commented 5 years ago

I think this issue needs to be re-opened because I have got this error simply by deleting my node_modules and re-running npm install from inside the root directory of the application. Running $ vue create project-name allows for npm run serve to work correctly.

microJ commented 5 years ago

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

sivang commented 5 years ago

I also get it, will check if @microJ 's solution fixes it.

PeterA1 commented 5 years ago

See...

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

Akryum commented 5 years ago

This issue seems to be caused by several user environment related issues (unrelated to vue-cli):

https://stackoverflow.com/questions/40546231/sh-react-scripts-command-not-found-after-running-npm-start https://stackoverflow.com/questions/47612580/react-scripts-command-not-found?rq=1 https://github.com/facebook/create-react-app/issues/3256#issuecomment-340259809 https://github.com/facebook/create-react-app/issues/3256#issuecomment-358406611 https://stackoverflow.com/questions/47842849/how-to-resolve-sh-react-scripts-command-not-found https://npm.community/t/npm-script-cant-find-module-without-the-full-path/1344/15

jassehomar commented 5 years ago

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

this works for me

ioslide commented 5 years ago

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

thanks

Seeker1437 commented 5 years ago

I did npm install and that was enough for me.

events-jonas-chrisw commented 5 years ago

Works if you run the "npm install" in "cmd", but not in powershell.

anselmobattisti commented 5 years ago

I'm using ubuntu inside windows 10. In my case the problem WAS the Malwarebytes :( it was blocking some update in my npm install!

jung-hunsoo commented 5 years ago

I got the same error in WSL ubuntu on Win 10.

My solution was to call ./node_modules/.bin/vue-cli-service; i.e. ./node_modules/.bin/vue-cli-service build --mode development.

0x77dev commented 5 years ago

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
0x77dev commented 5 years ago

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.

0x77dev commented 5 years ago

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

dmonti commented 5 years ago

The only thing that worked for me was going to plugins menu at Vue UI interface and download '@vue/cli-service' from there

svyatoslavratov commented 5 years ago

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.

maurelyo commented 5 years ago

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

0x77dev commented 5 years ago

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

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

nomadcalendar commented 5 years ago

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.

That resolved it for me, thanks!