-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"__dirname is not defined in ES module scope" in vite.config.js with module type in package.json #6946
Comments
This is expected and error is coming from Node. When you set |
Thanks for the link! However this is not mentioned in the documentation, which says that Vite will replace it:
Would it be possible to extend the Vite documentation so that other people don't have the same problem in the future?
|
the error message is also pretty clear |
In hindsight I agree but I was so fixated on Vite as it is written in the documentation ("Vite will replace") that I did not even consider that I have to do something with Node but thought this was a failure in some hidden Vite preprocessing step. |
Describe the bug
According to https://vitejs.dev/config/, vite.config.js may use ES module syntax and will replace __dirname. However when doing this in the following multi-page vite.config.js, it will fail.
vite.config.js
package.json
Reproduction
https://github.com/KonradHoeffner/multipage-bug
System Info
System: OS: Linux 5.12 Arch Linux CPU: (8) x64 Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz Memory: 10.60 GB / 15.42 GB Container: Yes Shell: 5.1.16 - /bin/bash Binaries: Node: 17.3.1 - /usr/bin/node npm: 8.5.0 - /usr/bin/npm Browsers: Chromium: 98.0.4758.80 npmPackages: vite: ^2.8.0 => 2.8.3
Used Package Manager
npm
Logs
Validations
The text was updated successfully, but these errors were encountered: