You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Google Chrome Version 113.0.5672.92 (Official Build) (64-bit)
Running in Sail?
No
Description
I created a new Laravel application by using Laravel installer v:4.5.0
The development server shows an error message that __dirname is not defined
However, even the error message is displayed, the development server continues to run and serves the application.
could be related to changes in the way Node.js handles the __dirname variable in ES modules.
Apart from this error message everything works fine.
My current approach might not be the most elegant or optimal solution, I would like to offer my temporary workaround for handling the error.
import { dirname } from "path";
import { fileURLToPath } from "URL";
And I have added the expression dirname(fileURLToPath(import.meta.url) in the place of previous __dirname
It would look like this fs.readFileSync(path.join(dirname(fileURLToPath(import.meta.url)), "dev-server-index.html")).toString().replace(/{{ APP_URL }}/g, appUrl)
Vite Plugin Version
0.7.5
Laravel Version
10.10.0
Node Version
18.6.0
NPM Version
9.5.1
Operating System
Windows (WSL)
OS Version
Windows 10 Pro: 22H2
Web browser and version
Google Chrome Version 113.0.5672.92 (Official Build) (64-bit)
Running in Sail?
No
Description
I created a new Laravel application by using Laravel installer v:4.5.0
The development server shows an error message that __dirname is not defined
However, even the error message is displayed, the development server continues to run and serves the application.
could be related to changes in the way Node.js handles the __dirname variable in ES modules.
Apart from this error message everything works fine.
My current approach might not be the most elegant or optimal solution, I would like to offer my temporary workaround for handling the error.
And I have added the expression
dirname(fileURLToPath(import.meta.url)
in the place of previous__dirname
It would look like this
fs.readFileSync(path.join(dirname(fileURLToPath(import.meta.url)), "dev-server-index.html")).toString().replace(/{{ APP_URL }}/g, appUrl)
return JSON.parse(fs.readFileSync(path.join(dirname(fileURLToPath(import.meta.url)), "../package.json")).toString())?.version;
Steps To Reproduce
laravel new app
npm install
npm run dev
The text was updated successfully, but these errors were encountered: