Vite dev server exits without message (fix in report)
See original GitHub issue- Laravel Vite Plugin Version: 0.1.3
- Laravel Version: 9.17.0
- Node Version: 18.3.0
- NPM Version: 8.11.0
Description:
When running the Vite dev server using npm run dev
, the development server starts up with
root@2731f07e003e:/app# npm run dev
> dev
> vite --host 0.0.0.0
vite v2.9.12 dev server running at:
> Local: http://localhost:3000/
> Network: http://172.21.0.4:3000/
ready in 506ms.
Laravel v9.17.0
> APP_URL: http://localhost
But closes unexpectedly a second after running the command with no messages or error messages whatsoever.
I did some debugging and commented out process.exit();
in
const clean = () => {
if (fs_1.default.existsSync(hotFile)) {
fs_1.default.rmSync(hotFile);
}
process.exit();
};
and this finally made the dev server spit out the following error
root@2731f07e003e:/app# npm run dev
> dev
> vite --host 0.0.0.0
vite v2.9.12 dev server running at:
> Local: http://localhost:3000/
> Network: http://172.21.0.4:3000/
ready in 448ms.
Laravel v9.17.0
> APP_URL: http://localhost
node:internal/errors:466
ErrorCaptureStackTrace(err);
^
Error: ENOSPC: System limit for number of file watchers reached, watch '/app/vendor/symfony/mailer/Transport/Smtp/Auth/XOAuth2Authenticator.php'
at FSWatcher.<computed> (node:internal/fs/watchers:244:19)
at Object.watch (node:fs:2306:34)
at createFsWatchInstance (/app/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:45512:17)
at setFsWatchListener (/app/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:45559:15)
at NodeFsHandler$1._watchWithNodeFs (/app/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:45714:14)
at NodeFsHandler$1._handleFile (/app/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:45778:23)
at NodeFsHandler$1._addToNodeFs (/app/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:46020:21)
Emitted 'error' event on FSWatcher instance at:
at FSWatcher._handleError (/app/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:47208:10)
at NodeFsHandler$1._addToNodeFs (/app/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:46028:18) {
errno: -28,
syscall: 'watch',
code: 'ENOSPC',
path: '/app/vendor/symfony/mailer/Transport/Smtp/Auth/XOAuth2Authenticator.php',
filename: '/app/vendor/symfony/mailer/Transport/Smtp/Auth/XOAuth2Authenticator.php'
}
Node.js v18.3.0
A fix for users that use this package on Linux is running this command
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
It will automatically adjust the system watcher limit and make the changes live.
Steps To Reproduce:
I am using Ubuntu 20.04.4 server LTS x86_64
and Docker version 20.10.16, build aa7e414
with Docker compose v2
- Clone
https://github.com/ericwang401/testing-laravel-vite
- Run
docker compose up -d
- Enter into the workspace container
docker compose exec workspace bash
- Install dependencies
composer i && npm i
- Start the dev server
npm run dev
(make sure you went into node_modules and commented outprocess.exit
in the Laravel Vite plugin cleanup function)
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
vite dev exits without any error message, explanation ... - GitHub
I was attempting to try out vite in a small rails application by following the Installation/Getting Started sections of the README. bundle exec ......
Read more >Troubleshooting - Vite
Switch to another package manager (e.g. pnpm , yarn ); Remove & from the path to your project. Dev Server #. Requests are...
Read more >Configuring Vite
Note Vite supports using ES modules syntax in the config file even if the project is not using native Node ESM via type:...
Read more >Server Options - Vite
When running Vite on WSL2, file system watching does not work when a file is edited by Windows applications (non-WSL2 process). This is...
Read more >Configuring Vite
... project is not using native Node ESM, e.g. type: "module" in package.json . ... during dev, the config is shared by the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Those are part of this framework PR https://github.com/laravel/framework/pull/42785 that we’ll be merging and releasing soon.
You can test it out now by running
composer require laravel/framework:"dev-vite as 9.11"
. You may need tophp artisan view:clear
if you’ve already tried to use the directives in your project.The Vite integration isn’t officially launched yet. We needed to publish the plugin early to test all the various starter kits and stacks.
Hi @ericwang401,
#17 should improve the exit and signal handling so that uncaught exceptions (including your file watcher issue) are output to the console, while still cleaning the
public/hot
file.I’ve verified this by using the command you mentioned above to set the watchers to
5
so that it always fails.