Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The requested module does not provide an export named #2

Open
JohnyDyxt opened this issue Feb 13, 2024 · 3 comments
Open

The requested module does not provide an export named #2

JohnyDyxt opened this issue Feb 13, 2024 · 3 comments

Comments

@JohnyDyxt
Copy link

Hi,

I got :

The requested module '/node_modules/vue-rewards/dist/vue-rewards.umd.cjs?import' does not provide an export named 'useReward'

Here's my code :

<script setup> import { useReward } from 'vue-rewards' const { reward: fullPageReward } = useReward('full-page', 'confetti', { startVelocity: 10, spread: 180, elementCount: 100 }) </script>

CONFIG :

@quasar/[email protected]
[email protected]

Thank for helping

@HamadaFMahdi
Copy link
Owner

Hi!

I just tried it with a fresh vue3 + vite project and it works fine.

Here's the one I made: https://codesandbox.io/p/devbox/vue-rewards-test-73q2ct

@JohnyDyxt
Copy link
Author

Hello and thank you for your response.

Unfortunately, it's impossible to get it to work at my place. Perhaps it's because I'm using the Quasar framework and their Vite plugin?

@cpilson
Copy link

cpilson commented Jun 4, 2024

This feels like a Quasar issue.

Specifically, it would be unsurprising if this page were the ultimate resolution; I'm new to Quasar and new to Vue so this is all fairly puzzling.

https://quasar.dev/app-extensions/tips-and-tricks/provide-a-ui-component/

@JohnyDyxt are you still struggling with this? There's at least TWO of us if so! (Update: I'm now using canvas-confetti, e-z.)

I took a swipe at it, no luck:

app/src/boot/vue-rewards.js:

import { boot } from 'quasar/wrappers';
import VueRewards, { useReward } from 'vue-rewards';

export default boot(({ app }) => {
  app.config.globalProperties.$VueRewards = VueRewards;
  app.config.globalProperties.$useReward = useReward;
});
export { useReward };

app/quasar.config.js:

// app boot file (/src/boot)
  // --> boot files are part of "main.js"
  // https://v2.quasar.dev/quasar-cli-vite/boot-files
  boot: [
    ...
    'vue-rewards',
  ],
  ...

Vue component where it's used:

<script setup lang="ts">
...
import { useReward } from 'src/boot/vue-rewards';
const { reward: fullPageReward } = useReward('full-page', 'confetti', { startVelocity: 10, spread: 180, elementCount: 100 });
...
        $q.notify({
          color: 'green-4',
          textColor: 'white',
          icon: 'cloud_done',
          message: 'Submitted',
          onDismiss: () => {
            fullPageReward();
            ctaDialog.value = false;
          }
        });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants