Error [ERR_REQUIRE_ESM]: require() of ES Module from quasar-config-file.js
See original GitHub issueWhat happened?
I am converting my app to Quasar CLI with Vite. Vite leverages ESM and thus it makes sense to use ESM for quasar.config.js
.
So I added "type":"module"
in package.json and converted the require
to import
e.g. this:
const { configure } = require('quasar/wrappers')
module.exports = configure(function (ctx) {
/* configuration options */
})
to this:
import { configure } from 'quasar/wrappers'
export default configure(function (ctx) {
/* configuration options */
})
What did you expect to happen?
I thought this could work when using Quasar CLI with Vite but it doesn’t work and errors show that node_modules\@quasar\app-vite\lib\quasar-config-file.js
doesn’t support ESM.
If that’s not a bug, then I suppose it should be a feature request that ESM works in a quasar created project with Quasar CLI with Vite.
Reproduction URL
no-reproduction
How to reproduce?
- Create a new quasar project and choose Quasar CLI with Vite
- Add “type”:“module” to package.json
- Change
quasar.config.js
to use ESM
Flavour
Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)
Areas
Quasar CLI Commands/Configuration (@quasar/cli | @quasar/app-webpack | @quasar/app-vite)
Platforms/Browsers
No response
Quasar info output
No response
Relevant log output
No response
Additional context
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
The node-fetch latest version doesn't use the require() syntax to import the package. You need to go to your package.json and type
Read more >Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
js to a dynamic import() which is available in all CommonJS modules" occurs because a package you are importing has been converted to...
Read more >require() of ES Module fix-path/index.js from main.ts ... - GitHub
App threw an error during load Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/manuel/src/electron-react-boilerplate/node_modules/fix-path/index.js ...
Read more >ERR_REQUIRE_ESM - DEV Community
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: ~/projects/semantic-release-toolkit/node_modules/zz/cjs.js require() of ES ...
Read more >Error [ERR_REQUIRE_ESM]: require() of ES Module - Support
js in /my-app/dist/graphql/resolvers/Mutations/site.js to a dynamic import() which is available in all CommonJS modules.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
Top GitHub Comments
In order to use ESM in quasar.config.js the whole q/app-vite CLI needs to be ESM too, because that’s the one loading this file. Due to time constraints, it’s not yet there. However, it will be in the future.
@rstoenescu Hi, any update about using ESM in quasar.config.js? I have a Vite plugin which is ESM only and I can’t attach it to quasar config.