Vite throwing ESM error during build

I had an issue where I tried to upgrade a Vue project which was built on vue-cli to use Vite instead. Things were fine until I tried to include Tailwind plugin for Vite.

The following error was showing up:

Failed to resolve "@tailwindcss/vite". This package is ESM only but it was tried to load by `require`. 
See https://vite.dev/guide/troubleshooting.html#this-package-is-esm-only for more details. [plugin externalize-deps]
    node_modules/esbuild/lib/main.js:1226:27:
      1226 │         let result = await callback({
           ╵                            ^

I tried to look at every config file I could find. Everything looked fine. After searching for solutions, I noticed someone in GitHub recommended changing the type in the package.json file to the module. This actually worked! Now it builds successfully.

A change in package.json file
Buy Me a Coffee at ko-fi.com

Add new comment