-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
✘ [ERROR] The symbol "__dirname" has already been declared #9109
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
Comments
See https://vitejs.dev/config/#configuring-vite. Removing the |
But I am getting this failed to load config from /home/mirzaahmedov/Web/Svelte/Learn/vite.config.js
error when starting dev server:
ReferenceError: __dirname is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/home/mirzaahmedov/Web/Svelte/Learn/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///home/mirzaahmedov/Web/Svelte/Learn/vite.config.js?t=1657804339765:18:30
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:409:24)
at async loadConfigFromFile (file:///home/mirzaahmedov/Web/Svelte/Learn/node_modules/vite/dist/node/chunks/dep-561c5231.js:62653:31)
at async resolveConfig (file:///home/mirzaahmedov/Web/Svelte/Learn/node_modules/vite/dist/node/chunks/dep-561c5231.js:62281:28)
at async createServer (file:///home/mirzaahmedov/Web/Svelte/Learn/node_modules/vite/dist/node/chunks/dep-561c5231.js:58899:20)
at async CAC.<anonymous> (file:///home/mirzaahmedov/Web/Svelte/Learn/node_modules/vite/dist/node/cli.js:699:24) |
I can't reproduce this. Are you using an older version of Vite? If not it would be helpful if you can provide a repro. There's also #9112 which may be similar to yours. |
I'm having the same issue, using Vite v3.0.0 and the Vue template |
Ah ok thanks for the hint. I can reproduce it locally too. |
This seems to happen in Vite 2 too. Looks like we're not handling this scenario well. vite/packages/vite/src/node/config.ts Lines 876 to 880 in 42a6d5b
|
Created repo And also having issue with svelte and sass. Non of my aliases working inside of style tags <style lang="scss">
@use "@/styles/global.scss";
</style> |
Describe the bug
my vite.config.js
if I run npm run dev I get "✘ [ERROR] The symbol "__dirname" has already been declared" error
if I remove type: "module" from package.json everything works fine
Reproduction
npm run dev
System Info
Used Package Manager
npm
Logs
Validations
The text was updated successfully, but these errors were encountered: