Vite uses ESM imports, require isn't available, it's only available when Node uses CommonJS. Switch to using import and from instead.
import Vapor from 'laravel-vapor'
You can read more in the PR that added Vite support.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
We are using Vapor with AWS Lambdas, and I cannot seem to get the asset helper working in javascript, at least locally it doesn't work. I following the documentation installing the necessary library with
npm install --save-dev laravel-vapor
then adding this to app.js
window.Vapor = require('laravel-vapor');
This just gives the error that require isn't a valid command, so somehow the code isn't being built correctly on my local machine. NOTE: we are using Inertia with Vue 3 and Vite, so I'm sure this is part of the issue. Any help is appreciated, is there a specific process to run a Vapor app locally, we are using Sail to run the app locally.
Please or to participate in this conversation.