Skip to content

Vite dev server cannot find php binary — Wayfinder type generation fails on startup #381

Description

@alejandroperezpujante

Description

When starting the Vite dev server via lerd web ui, the @laravel/vite-plugin-wayfinder plugin fails immediately during its buildStart hook because the php binary is not available in the environment where the Vite process runs.

This works correctly when running npm run dev from a terminal that has php on its PATH.


Steps to reproduce

  1. Create a new Laravel project using the Vue starter kit:
laravel new myapp --using=laravel/vue-starter-kit
  1. Link the project with lerd link (make sure Vite is checked).
  2. Observe the error in the linked site in the lerd UI.

Error output

Error: Error generating types: Error: Command failed: php artisan wayfinder:generate --with-form
/bin/sh: php: command not found
at PluginContext._formatLog (file:///Users/username/myapp/node_modules/vite/dist/node/chunks/node.js:30486:39)
at PluginContext.error (file:///Users/username/myapp/node_modules/vite/dist/node/chunks/node.js:30483:14)
at runCommand (file:///Users/username/myapp/node_modules/@laravel/vite-plugin-wayfinder/dist/index.mjs:2101:15)
at async Promise.all (index 2)
at async EnvironmentPluginContainer.hookParallel (file:///Users/username/myapp/node_modules/vite/dist/node/chunks/node.js:30130:3)
at async EnvironmentPluginContainer.buildStart (file:///Users/username/myapp/node_modules/vite/dist/node/chunks/node.js:30140:3)
at async file:///Users/username/myapp/node_modules/vite/dist/node/chunks/node.js:26358:41
at async httpServer.listen (file:///Users/username/myapp/node_modules/vite/dist/node/chunks/node.js:26369:5) {
  plugin: '@laravel/vite-plugin-wayfinder'
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions