[Quasar CLI + Vite + SSR] Build generates require() instead of import, resulting in ERR_REQUIRE_ESM #13726
Replies: 7 comments 3 replies
-
Same problem with Swiper.js. Did you fixed it? |
Beta Was this translation helpful? Give feedback.
-
@gustavotoyota Did you manage to solve it without creating a boot file? I have the same issue but with
|
Beta Was this translation helpful? Give feedback.
-
The same problem has with vue-openlayers 3.0.0-3
|
Beta Was this translation helpful? Give feedback.
-
I have the same issue with swiper.js as well. |
Beta Was this translation helpful? Give feedback.
-
Yep same problem with swiper.js, as well as apollo client. This is seriously hindering development. |
Beta Was this translation helpful? Give feedback.
-
Hi I also have the same problem. Currently working around it by using await import(...); which is kind of irritating and troublesome sometimes when asynchronous code is undesired. In fact, it is worse than irritating. Recently, I ran a quasar build -m ssr --publish, and it generated a server-entry.js which replaced my "await import" with "require" for some unknown reason which caused it not to work. I tried to simply replace "require" with "await import" directly in the server-entry.js file, and that did not work either. In the end I had to replace the entire library with another equivalent which used CommonJS instead of ESM. It is very very strange that ESM does not work and gets replaced with require() when just about all modules released nowadays are ESM. |
Beta Was this translation helpful? Give feedback.
-
I'm trying to load lowlight as a dependency, which is an ESM module.
When trying to run my server built with
quasar build -m ssr
I'm receiving this error:Error [ERR_REQUIRE_ESM]: require() of ES Module \node_modules\lowlight\index.js from \dist\ssr\server\server-entry.js not supported.
Looking into the file \dist\ssr\server\server-entry.js I see that my
import { lowlight } from 'lowlight'
becamerequire('lowlight')
in the output, resulting in the error above.Why is the build replacing my ES6 imports with CommonJS imports?
How do I fix this?
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions