I'm currently getting this error when building my ESM project:
failed to load config from ......./vite.config.ts
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 '......./package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///......./node_modules/.pnpm/unplugin@0.2.4_vite@2.5.1/node_modules/unplugin/dist/index.mjs:226:40
at ModuleJob.run (internal/modules/esm/module_job.js:170:25)
at async Loader.import (internal/modules/esm/loader.js:178:24)
at async loadConfigFromFile (.......\node_modules.pnpm\vite@2.5.1\node_modules\vite\dist\node\chunks\dep-972722fa.js:75819:31)
at async resolveConfig (.......\node_modules.pnpm\vite@2.5.1\node_modules\vite\dist\node\chunks\dep-972722fa.js:75434:28)
at async createServer (.......\node_modules.pnpm\vite@2.5.1\node_modules\vite\dist\node\chunks\dep-972722fa.js:73957:20)
at async CAC. (.......\node_modules.pnpm\vite@2.5.1\node_modules\vite\dist\node\cli.js:13963:24)
I'm currently getting this error when building my ESM project: