JeremyK's avatar

Error when running vite server

Created a new project with the following commands:

composer create-project laravel/laravel testapp

php artisan migrate

composer require laravel/breeze --dev

php artisan breeze:install blade

when I try to start the vite development server using "npm run dev" I get the follwing error.

 > dev
 > vite


  VITE v4.5.0  ready in 2741 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h to show help

  LARAVEL v10.28.0  plugin v0.8.1

  ➜  APP_URL: http://localhost
node:internal/errors:496
    ErrorCaptureStackTrace(err);
    ^

Error: UNKNOWN: unknown error, watch
    at FSWatcher._handle.onchange (node:internal/fs/watchers:207:21)
Emitted 'error' event on FSWatcher instance at:
    at FSWatcher._handleError (file:///M:/code/testapp/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:53803:10)
    at NodeFsHandler._boundHandleError (file:///M:/code/testapp/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:52278:43)
    at file:///M:/code/testapp/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:52122:5
    at foreach (file:///M:/code/testapp/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:52026:5)
    at fsWatchBroadcast (file:///M:/code/testapp/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:52121:3)
    at FSWatcher.<anonymous> (file:///M:/code/testapp/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:52170:9)
    at FSWatcher.emit (node:events:514:28)
    at FSWatcher._handle.onchange (node:internal/fs/watchers:213:12) {
  errno: -4094,
  syscall: 'watch',
  code: 'UNKNOWN',
  filename: null
}

Node.js v18.17.0

Any help appreciated. Thanks

0 likes
1 reply
LaryAI's avatar
Level 58

This error is related to file watching in Vite. It seems that there is an issue with the file system watcher in your environment. Here are a few steps you can try to resolve the issue:

  1. Make sure you have the latest version of Node.js installed. You mentioned that you are using Node.js v18.17.0, which is not a valid version. The latest LTS version at the time of writing is 14.17.6. You can download it from the official Node.js website: https://nodejs.org/

  2. Clear the cache and reinstall the dependencies. Run the following commands in your project directory:

npm cache clean --force
rm -rf node_modules
npm install
  1. If you are using a Windows operating system, try running your terminal or command prompt as an administrator. This can sometimes resolve file watching issues.

  2. Disable any antivirus or security software temporarily and see if the issue persists. Sometimes, these programs can interfere with file watching.

  3. If none of the above steps work, try using a different terminal or command prompt. Some terminals have limitations or conflicts with file watching.

If the issue still persists, you can try posting your question on the Laracasts forum or the Vite GitHub repository for further assistance.

Please or to participate in this conversation.