Vue-cli: Building generated project failed due to vue-cli-service command not found

Created on 10 Apr 2018  ยท  35Comments  ยท  Source: vuejs/vue-cli

I created a new Vue project using the vue create command. I managed to build it properly on my MacOS platform, but on a CentOS 6.9 platform the build fails with the following error message:
sh: vue-cli-service: command not found

I found a workaround by modifying package.json as follows:

"scripts": {
    "serve": "./node_modules/\\@vue/cli-service/bin/vue-cli-service.js serve --open",
    "build": "./node_modules/\\@vue/cli-service/bin/vue-cli-service.js build",
    "lint": "./node_modules/\\@vue/cli-service/bin/vue-cli-service.js lint"
},

Version

3.0.0-beta.6

Reproduction link

This is random link, do not open! I cannot reproduce in these places.
https://jsfiddle.net/chrisvfritz/50wL7mdz/

Steps to reproduce

Install latest npm, latest vue-cli and try to build a Vue project in CentOS 6.9

What is expected?

The build should succeed

What is actually happening?

$ npm run build

> [email protected] build /mnt/partition/home/photoccino/src/apc-tools/moo/frontend
> vue-cli-service build

sh: vue-cli-service: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] build: `vue-cli-service build`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/photoccino/.npm/_logs/2018-04-10T06_37_11_606Z-debug.log

$ cat /home/photoccino/.npm/_logs/2018-04-10T06_37_11_606Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'build' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle [email protected]~prebuild: [email protected]
6 info lifecycle [email protected]~build: [email protected]
7 verbose lifecycle [email protected]~build: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~build: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/mnt/partition/home/photoccino/src/apc-tools/moo/frontend/node_modules/.bin:/usr/local/bin:/usr/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/photoccino/bin
9 verbose lifecycle [email protected]~build: CWD: /mnt/partition/home/photoccino/src/apc-tools/moo/frontend
10 silly lifecycle [email protected]~build: Args: [ '-c', 'vue-cli-service build' ]
11 info lifecycle [email protected]~build: Failed to exec build script
12 verbose stack Error: [email protected] build: `vue-cli-service build`
12 verbose stack spawn ENOENT
12 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
12 verbose stack     at emitTwo (events.js:126:13)
12 verbose stack     at ChildProcess.emit (events.js:214:7)
12 verbose stack     at maybeClose (internal/child_process.js:925:16)
12 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
13 verbose pkgid [email protected]
14 verbose cwd /mnt/partition/home/photoccino/src/apc-tools/moo/frontend
15 verbose Linux 2.6.32-131.17.1.el6.x86_64
16 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "build"
17 verbose node v8.11.1
18 verbose npm  v5.8.0
19 error file sh
20 error code ELIFECYCLE
21 error errno ENOENT
22 error syscall spawn
23 error [email protected] build: `vue-cli-service build`
23 error spawn ENOENT
24 error Failed at the [email protected] build script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]

Most helpful comment

If anybody is still facing this issue, i was able to solve it on MacOS by installing _globally_ @vue/cli-service-global.

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

Which popped out when running vue serve:

  Command vue serve requires a global addon to be installed.
  Please run yarn global add @vue/cli-service-global and try again.

Hope it helps, Cheers!

All 35 comments

The vue-cli-service script is installed in my local node_modules directory, but the install script does not find it:

$ ./node_modules/\@vue/cli-service/bin/vue-cli-service.js 

  Usage: vue-cli-service <command> [options]

  Commands:

    serve     start development server
    build     build for production
    inspect   inspect internal webpack config
    lint      lint and fix source files

  run vue-cli-service help [command] for usage of a specific command.

$ npm run build

> [email protected] build /mnt/partition/home/photoccino/src/apc-tools/moo/frontend
> vue-cli-service build

sh: vue-cli-service: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] build: `vue-cli-service build`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/photoccino/.npm/_logs/2018-04-10T08_15_47_643Z-debug.log

In package.json:

"scripts": {
    "serve": "vue-cli-service serve --open",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },

This bug could be related to unstable npm installation due to crash in the installation stage: https://github.com/npm/npm/issues/20295

You may close this ticket if you think there is not further issues related to vue-cli

can you test with any other npm binary? For example npm i cat-ascii-faces, and then add a script entry that runs cat-face
If it also fails, then it is something dealing with npm/your os

i'm having the same issue with beta 11

even creating a new project seems to cause it for me

Vue CLI v3.0.0-beta.11
โœจ  Creating project in /Users/seb/dev/Barrys/scratch/barrys-ui.
๐Ÿ—ƒ  Initializing git repository...
โš™  Installing CLI plugins. This might take a while...

yarn install v1.6.0
info No lockfile found.
[1/4] ๐Ÿ”  Resolving packages...



success Saved lockfile.
โœจ  Done in 9.43s.
โ 
๐Ÿš€  Invoking generators...
 ERROR  Error: Failed to resolve plugin: @vue/cli-service
Error: Failed to resolve plugin: @vue/cli-service
    at Creator.resolvePlugins (/Users/seb/.nvm/versions/node/v8.10.0/lib/node_modules/@vue/cli/lib/Creator.js:288:15)
    at Creator.create (/Users/seb/.nvm/versions/node/v8.10.0/lib/node_modules/@vue/cli/lib/Creator.js:137:32)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

updated yarn and node w/ no effect

Vue CLI v3.0.0-beta.11
โœจ  Creating project in /Users/seb/dev/Barrys/scratch/barrys-ui.
๐Ÿ—ƒ  Initializing git repository...
โš™  Installing CLI plugins. This might take a while...

yarn install v1.7.0
info No lockfile found.
[1/4] ๐Ÿ”  Resolving packages...
[2/4] ๐Ÿšš  Fetching packages...
[3/4] ๐Ÿ”—  Linking dependencies...
[4/4] ๐Ÿ“ƒ  Building fresh packages...

success Saved lockfile.
โœจ  Done in 7.09s.

๐Ÿš€  Invoking generators...
 ERROR  Error: Failed to resolve plugin: @vue/cli-service
Error: Failed to resolve plugin: @vue/cli-service
    at Creator.resolvePlugins (/Users/seb/.nvm/versions/node/v8.11.1/lib/node_modules/@vue/cli/lib/Creator.js:288:15)
    at Creator.create (/Users/seb/.nvm/versions/node/v8.11.1/lib/node_modules/@vue/cli/lib/Creator.js:137:32)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

turns out it was a yarn / nvm conflict - i was loading yarn global after nvm in my .zshrc

This error is occuring for me after a fresh vue cli install and running the command :
vue create some_project_name

Error:
๐Ÿš€ Invoking generators... ERROR Error: Failed to resolve plugin: @vue/cli-service Error: Failed to resolve plugin: @vue/cli-service at Creator.resolvePlugins (C:\Users\sheld\AppData\Roaming\npm\node_modules\@vue\cli\lib\Creator.js:303:15) at Creator.create (C:\Users\sheld\AppData\Roaming\npm\node_modules\@vue\cli\lib\Creator.js:146:32) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7)

Vue CLI version:
Vue CLI v3.0.0-beta.14

Same here. Tried beta12 and beta14.
Env: win10, native console or gitbash/mingw64
Worked well with beta1 :-)

Occurs here as well in Windows 10 env with:

  • Vue CLI v3.0.0-beta.14
  • NPM 6.1.0
  • Cmder running git bash OR Cygwin 64 terminal

Extra notes:

  • Same Vue CLI and NPM versions work fine in a Linux environment
  • node_modules/@vue/cli-service directory exists

I think it's an nvm issue. For me at least switching to a regular node install works, where using nvm gave me the error

I fixed this by :

  • uninstalling my current version of node (10.3.0) and installing the latest stable version (8.11.2)
  • Uninstalling @ vue/cli package (npm remove -g @ vue/cli )
  • and as mentioned by @prinzt installing vue/cli beta-1 (npm install -g @ vue/[email protected])

EDIT: When typing in " @ and vue/cli together as one word, it removes from the text displayed. For clarity, I've added a space between the @ sign and the vue/cli. Don't copy paste these commands unless you plan on removing the space your self.

Note: working on a windows 10 env

Same fix worked for me as well, upgraded to the latest stable version of node(8.11.2) and latest version of npm (6.1.0). That fixed the issue for me for windows 10

Upgrading Vue CLI from beta 14 to beta 15 seems to have fixed the issue for me at this moment:

npm update -g @vue/cli

No Node or NPM updates needed.

Upgrade to beta 15 did NOT resolve the issue for me. I was about to submit a new issue when I found this thread. Here's what I was about to post:

Version

3.0.0-beta.15

Reproduction link

Given that this is a tooling issue, I don't know how to reproduce online. Description below is for project generation using the GUI. However I also tried the exact same set of configuration options using $vue create my-app and I got the same error.

Steps to reproduce

  1. Launch the GUI: $ vue ui
  2. Select the "Create" tab
  3. Click the "Create a new project here" button
  4. Enter a project name, select npm as package manager, do NOT overwrite, click "Next"
  5. Select "Manual" preset, click "Next"
  6. Enable ALL features EXCEPT TypeScript, click "Create Project"
  7. Click "continue without saving" (i.e. don't save this config as a preset)
  8. Click "Create Project"

NOTE: The first time I did this, it asked me to specify options. The second time, it did not. Here's what I chose the first time:

  • Lint on Save
  • Config in dedicated config files
  • CSS preprocessor: SCSS/SASS
  • Linter: ESLint + Prettier
  • Unit Testing Framework: Jest
  • E2E Framework: Cypress

What is expected?

I expected a new project to be created and initialized in the target directory specified.

What is actually happening?

Project creation failed with the following error message (note: file path anonymized):

๐Ÿš€  Invoking generators...
Error: Failed to resolve plugin: @vue/cli-service
    at Creator.resolvePlugins (/Users/myusername/.nvm/versions/node/v9.0.0/lib/node_modules/@vue/cli/lib/Creator.js:303:15)
    at Creator.create (/Users/myusername/.nvm/versions/node/v9.0.0/lib/node_modules/@vue/cli/lib/Creator.js:146:32)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

Some additional information about my dev machine:

OSX 10.13.4
Using NVM
Node: v9.0.0
NPM: v6.1.0

Output of npm list -g --depth=0:

/Users/myusername/.nvm/versions/node/v9.0.0/lib
โ”œโ”€โ”€ @angular/[email protected]
โ”œโ”€โ”€ @vue/[email protected]
โ”œโ”€โ”€ [email protected]
โ”œโ”€โ”€ [email protected]
โ”œโ”€โ”€ [email protected]
โ”œโ”€โ”€ [email protected]
โ”œโ”€โ”€ [email protected]
โ”œโ”€โ”€ [email protected]
โ”œโ”€โ”€ [email protected]
โ”œโ”€โ”€ [email protected]
โ”œโ”€โ”€ [email protected]
โ”œโ”€โ”€ [email protected]
โ””โ”€โ”€ [email protected]

npm ERR! peer dep missing: [email protected], required by [email protected]
npm ERR! peer dep missing: [email protected], required by [email protected]

What packages were installed in the project?

In my case, it was a brand new project, so only default packages were installed. The failure happens when using vue create my-app from the command line, or otherwise trying to do vue ui and then generate a new project through the web interface. I've tried with the default preset as well, and still got the same error. If I cd into the directory and type which vue-cli-service I get ./node_modules/.bin/vue-cli-service so I'm pretty sure the command should be findable in the environment.

@Akryum likely the resolveModule fallback version check is not taking 9.x into consideration. Looks like 9.0.0 does not support require.resolve options.

@morphatic it should work if you use Node 8.x or 10.x for now.

I got it working (based on Evan's hint). Here's what I did:

  1. Upgraded nvm (from v0.32.1 -> v0.33.11)
  2. Installed latest node (v10.3.0)
  3. Re-installed vue cli (v3.0.0-beta.15)
  4. Used GUI to generate new project with same settings as above

Based on that, it's hard to say whether the ultimate cause of the hangup was the version of NVM or the version of Node, but my guess is that it is a Node version issue.

Node 9.0.0 has the paths option: https://github.com/nodejs/node/blob/fa9990f3fb5b06fe94e294925246d2c136deb2c2/lib/module.js#L517-L534
So I don't think this is the cause of the issue.

I came across this thread with the same problem only I continued to have this problem using Windows 10 despite installing the latest stable version (8.11.2) of node and upgrading to npm (6.1.0). The problem it seems was upgrading npm to 6.1.0 using npm.

For anyone else with this problem using windows10 and wondering why their installation still isn't working, here there is a tool provided by windows:

https://github.com/felixrieseberg/npm-windows-upgrade.

Initially installing and running as described still did not work. I had to follow _all_ the troubleshooting steps mentioned:

  • Uninstall Node.js (select Uninstall, not the Repair option).
  • Go into %programfiles%nodejs and delete the entire folder.
  • Delete %appdata%npm and %appdata%npm-cache.
  • Edit your PATH and remove everything that references npm (to do so, hit "Start" and search for "Environment Variables").
  • Reinstall Node, and then follow the instructions using the npm-windows-upgrade tool, and only use this tool to upgrade npm, do not attempt to run npm install npm.

The windows npm upgrade tool was linked to from npmjs troubleshooting here: https://docs.npmjs.com/troubleshooting/try-the-latest-stable-version-of-npm

But I now also have windows 10 running 3.0.0-beta.15 with Node (8.11.2) of node and npm (6.1.0).

small correction - I have to use the vue ui to create the projects, so the web interface is working for me but not the command line.

Still get the Error: Failed to resolve plugin: @vue/cli-service
using the command line vue create my-project.

If anybody is still facing this issue, i was able to solve it on MacOS by installing _globally_ @vue/cli-service-global.

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

Which popped out when running vue serve:

  Command vue serve requires a global addon to be installed.
  Please run yarn global add @vue/cli-service-global and try again.

Hope it helps, Cheers!

I also ran into this error when creating a new @vue/cli project (3.0.0-beta.16) with default settings with Node 9.11.1. I resolved the issue using a similar procedure as above:

  1. Update to Node 10.4.1 (and npm 6.1.0)
  2. Reinstall @vue/cli
  3. Do a clean reinstall of project's node_modules

I'm using n.

+1
But! I do npm run build and again npm run serve. And it's work!

Same error here too.
node: v9.9.0
vue-cli v3.0.0-rc.5

"But! I do npm run build and again npm run serve. And it's work!"

Same here lol

My co-worker and I are also having this problem on OSX using Node 8.10.0 and npm 6.1.0 with the addition of using Yarn Workspaces and my personal use of nodenv.

On my computer, installing 3.0.0-beta.15 works fine on my computer but does not work on my co-workers computer.

Upgrading to 3.0.0-rc.5 does _NOT_ work for me as it is failing to install the .bin in both the workspace's package _AND_ in the root node_modules folder.

Reverting the upgrade and re-running yarn install re-installs the beta.15 .bin file and the app works again. ยฏ_(ใƒ„)_/ยฏ

Getting this with 3.0.0-rc.8. The binary is installed fine locally and I can build without problems, but when I try to deploy to Google Cloud App Engine it throws 404 Not Found: vue-cli-service@latest.

Running [email protected] on
This error occurred for me following the use of npm-check-update (ncu v2.14.2):

> [email protected] serve /mnt/sda1/simon/Documents/GitHub/landingpages
> vue-cli-service serve

sh: 1: vue-cli-service: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] serve: `vue-cli-service serve`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the [email protected] serve script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/simon/.npm/_logs/2018-10-31T17_53_51_450Z-debug.log

To fix this I ran npm install in the directory . Things worked after this.

This error was showing up in my CI environment (CodeShip Ubuntu 14.04). The details below got me unstuck.

With the --production flag (or when the NODE_ENV environment is set to production), npm will not install modules listed in devDependencies."

echo $NODE_ENV
production
npm config get production
true
npm config set -g production false
npm install
npm run build
... all good ...

This will load all dev dependencies including @vue/cli-service which may or may not be desirable depending on what environment you are building for.

I have install

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

but when I do vue upgrade, it still gives me this:

$ vue upgrade

  Command vue upgrade requires a global addon to be installed.
  Please run yarn global add @vue/cli-upgrade and try again.

:thinking: :thinking: :question:

my ~/.vuerc

{
  "packageManager": "npm",
  "presets": {
    "SFC TS": {
      "useConfigFiles": true,
      "plugins": {
        "@vue/cli-plugin-babel": {},
        "@vue/cli-plugin-typescript": {
          "classComponent": true,
          "tsLint": true,
          "lintOn": [
            "save",
            "commit"
          ],
          "useTsWithBabel": true
        }
      }
    },
    "plain": {
      "useConfigFiles": false,
      "plugins": {}
    }
  },
  "useTaobaoRegistry": false
}

Got this error, I think due to nvm switching node version.
was able to fix with just
npm uninstall vue-cli -g && npm i vue-cli -g

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

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

This works well. Thank you.

Here's a link to the current nvm version, for anyone needing this fix in 2020 or beyond

Click me

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eladcandroid picture eladcandroid  ยท  3Comments

CodeApePro picture CodeApePro  ยท  3Comments

joshuajohnson814 picture joshuajohnson814  ยท  3Comments

miyamoto-san picture miyamoto-san  ยท  3Comments

csakis picture csakis  ยท  3Comments