I was working with Vite and using a script for development: vite --watch and it was working properly, watching my files change and doing HMR correctly, until I stopped the container and started working on another project. After that, this first project of mine hasn't been able to use --watch anymore. The error it raises when I ru nthe container is the following:
vitest | > dev
vitest | > vite --watch
vitest |
vitest | file:///var/www/html/node_modules/vite/dist/node/cli.js:443
vitest | throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);
vitest | ^
vitest |
vitest | CACError: Unknown option `--watch`
vitest | at Command.checkUnknownOptions (file:///var/www/html/node_modules/vite/dist/node/cli.js:443:17)
vitest | at CAC.runMatchedCommand (file:///var/www/html/node_modules/vite/dist/node/cli.js:641:13)
vitest | at CAC.parse (file:///var/www/html/node_modules/vite/dist/node/cli.js:580:12)
vitest | at file:///var/www/html/node_modules/vite/dist/node/cli.js:894:5
vitest | at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
vitest | at async Promise.all (index 0)
vitest | at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
vitest | 2023-03-06 18:00:20,498 INFO exited: vue (exit status 1; not expected)
vitest |
vitest | INFO Server running on [http://0.0.0.0:8000].
vitest |
vitest | Press Ctrl+C to stop the server
Anyone knows what is this and what I can do to fix this?
It looks like the --watch flag is not being recognized by Vite. This could be due to a few different things.
First, make sure you are running the latest version of Vite. You can check this by running npm list vite in your project directory. If the version is not up to date, run npm install vite to update it.
If the version is up to date, try running vite clean to clear the cache and then try running vite --watch again.
If that doesn't work, try running vite --version to make sure the version of Vite you are running is compatible with the --watch flag.
If all else fails, you can try reinstalling Vite with npm uninstall vite followed by npm install vite.
Hopefully one of these solutions will help you get the --watch flag working again.