6

If I execute the following commands from the root of my Vue app (v. 2.6.12)

rm -rf node_modules
npm install
npm run serve

I get the following error

sh: vue-cli-service: command not found

If I manually add the following symlink to node_modules/.bin the error does not occur

vue-cli-service -> ../@vue/cli-service/bin/vue-cli-service.js

But I shouldn't have to do this manually, i.e. if this symlink is required, it should be created when the @vue/cli-service package is installed.

I'm using NPM version 7.0.3 and have the following declared in the devDependencies section of package.json

"@vue/cli-service": "^4.5.6"
4
  • 1
    Will you look at github issue: github.com/vuejs/vue-cli/issues/2404 Commented Dec 16, 2020 at 14:41
  • Sometimes caching is the problem.can you try npm run cache clean --force and delete package-lock.json and try to install again. Commented Dec 16, 2020 at 14:52
  • 1
    Can you reproduce this error in another repo and post the link or post the link to the repo with the error? This is most likely a problem with installing the packages, or a cache issue with npm. As an alternative, try using yarn and see if that works better. Commented Dec 16, 2020 at 20:21
  • please share your package.json file Commented Dec 19, 2020 at 9:53

5 Answers 5

3
+150

You may be able to skirt the issue by using the following in your package.json:

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

OR

"serve": "node ./node_modules/@vue/cli-service/bin/vue-cli-service.js serve"

This is just a temporary fix, though, as it is most likely an issue with npm not setting the correct path or npm not installing the binary properly. Try upgrading npm and nvm. See @bravemaster's comment on the github issue, as this contains several potential fixes.

Sign up to request clarification or add additional context in comments.

Comments

1

Vue cli must be installed with global flag.

npm install -g vue-cli-service

If error try same command with sudo.

Vue-cli should not be in your package.json as a dependency (not even in dev-dependencies) because it is used only to generate a new project from scratch, not being necessary to run/server/build a project. (in dev or production), as the scripts are set in scripts section from package.json.

Comments

1

npm install worked for me in the past, but check the package.json, which should roughly like this:

"scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
},
...
"devDependencies": {
    ...
    "@vue/cli-service": "~4.5.0",
    ...
},

Comments

1

Replacing NPM with Yarn 1.X resolved this issue

Comments

0

I had this issue with many of my projects using vue-cli-service. I migrated to vite. My projects worked.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.