I am installing a plugin in Vite, but I run into an error message stating that the package only supports ESM, not CJS.
package.json
{"devDependencies": {"example-package": "^1","vite": "^6" }}
vite.config.js
import { defineConfig } from "vite";import examplePlugin from "example-package"; // that's ESM import, whats a problem?export default defineConfig({ plugins: [ examplePlugin(), ],});
✘ [ERROR] Failed to resolve "example-package". This package is ESM only but it was tried to load by
require
. [plugin externalize-deps]
I have installed the package correctly via npm, as the import is handled properly in the vite.config.js
file. So what is the issue with ESM import?