question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error [ERR_REQUIRE_ESM]: require() of ES Module from quasar-config-file.js

See original GitHub issue

What 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?

  1. Create a new quasar project and choose Quasar CLI with Vite
  2. Add “type”:“module” to package.json
  3. 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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
rstoenescucommented, Mar 16, 2022

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.

1reaction
eladcandroidcommented, Jul 8, 2022

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found