Search code examples
vue.jsvuejs3vite

Vue.js Error while running task C:\xxxxx:build with message'spawn vite ENOENT'


I am having the error :

Error while running task C:\xxxxx:build with message'spawn vite
ENOENT'

I am using Vue 3, with Vue UI and my node version is v18.16.0

I installed this template for Vue with Bootstrap : https://www.creative-tim.com/product/vue-material-kit

It works fine when I run the dev version from Vue UI, website is running OK and I can modify files to customize the components.

But when I try to build a version for prod, I get the error :

Error while running task C:\xxxxx:build with message'spawn vite
ENOENT'

It seems to have a problem with Vite, but I never used it before and I cannot figure out what is the problem.

I found some posts on ENOENT errors, but not a single one related to Vite.

Here is the vite.config.js file which is in the project root :

import { fileURLToPath, URL } from "url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
});

I have no clue at the moment and my only idea is to totally remove Vite, but it seems to be a good dependency and I'd like to keep it.


Solution

  • Fixed it by closing and relaunching vue UI, the previous session was launched for few days before I started to work on this project.

    Not sure what was the exact reason but it seems the real error was raised by vue cli and hidden by the Vui UI displaying Vite level error.

    My guess is that pre-launched Vue UI for some reasons didn't auto update installed dependencies from npm. It's usually not a problem for my projects, but maybe Vite is changing the workflow.

    Here is how I found it :

    • When reading the console which launched the Vue UI, I noticed some additional errors :
    Error: spawn vite ENOENT
        at notFoundError (C:\xxxxx\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\cross-spawn\lib\enoent.js:6:26)
        at verifyENOENT (C:\xxxxx\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\cross-spawn\lib\enoent.js:40:16)
        at cp.emit (C:\xxxxx\AppData\Roaming\npm\node_modules\@vue\cli\node_modules\cross-spawn\lib\enoent.js:27:25)
        at ChildProcess._handle.onexit (node:internal/child_process:291:12) {
      code: 'ENOENT',
      errno: 'ENOENT',
      syscall: 'spawn vite',
      path: 'vite',
      spawnargs: [ 'build', '--no-modern', '--dashboard' ]
    }
    

    Step 3. re-import in the visualization panel.