Vitest test fails. require() of ES modules is not supported #3757
Replies: 5 comments 4 replies
-
Failing with same issue, already spent 2 full days looking for solution. Part solution:
but again than I am stuck to import .css to it. Crazy err. Anyone find some solution for this please. |
Beta Was this translation helpful? Give feedback.
-
bump having the same issue as well |
Beta Was this translation helpful? Give feedback.
-
were u able to solve this? |
Beta Was this translation helpful? Give feedback.
-
im having the same issues as well |
Beta Was this translation helpful? Give feedback.
-
Same issue. |
Beta Was this translation helpful? Give feedback.
-
Hey Y'all, I am currently migrating one of my works repos from CRA and jest to vite/vitest. The migration to vite was no issue, however, with vitest I am having an issue that is causing around 35 tests to fail.
The error is "Must use import to load ES Module." Require() of ES modules is not supported.
It says its coming from a few modules in my node_modules, specifically, lodash-es, @mapbox, and @deck.gl.
I have been stuck on this for a week now with no avail. I am aware that vitest is ESM first, and cant use CJS, I just cant find a way to resolve these requires() to imports from these modules. If anyone has any ideas on how to fix this please reach out!
Here is my setup.
vite.config.ts
import { defineConfig } from 'vite'
import { vitest } from 'vitest/config'
Beta Was this translation helpful? Give feedback.
All reactions