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.

[v4][Vue warn]: provide() can only be used inside setup() with the Nuxt3

See original GitHub issue

What happened?

I have implemented a simple page that uses useField according to this document. I deployed the above page to AWS Lambda using Nuxt(3.0.0-rc.4) Nitro, and I am getting following warnings during SSR(This does not occur during client-side rendering). Curiously, this problem does not occur on a local server started by nuxt dev.

[Vue warn]: provide() can only be used inside setup()
[Vue warn]: inject() can only be used inside setup() or functional components.
[Vue warn]: onMounted is called when there is no active component instance to be associated with.

index.vue

<template>
  <div>
    <input v-model="value" />
    <span>{{ errorMessage }}</span>
  </div>
</template>
<script>
import { useField } from 'vee-validate';
export default {
  setup() {
    // a simple `name` field with basic required validator
    const { value, errorMessage } = useField('name', (inputValue) => !!inputValue);
    return {
      value,
      errorMessage,
    };
  },
};
</script>

My apologies if this is not a bug in vee-validate. Any help would be greatly appreciated.

Reproduction steps

  1. Implement the sample page.
  2. Build the app by the nuxt build
  3. Deploy the app to AWS Lambda . …

Version

Vue.js 3.x and vee-validate 4.x

What browsers are you seeing the problem on?

  • Firefox
  • Chrome
  • Safari
  • Microsoft Edge

Relevant log output

[Vue warn]: provide() can only be used inside setup()
[Vue warn]: inject() can only be used inside setup() or functional components.
[Vue warn]: inject() can only be used inside setup() or functional components.
[Vue warn]: inject() can only be used inside setup() or functional components.
[Vue warn]: onMounted is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.


### Demo link

no link

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](CONDUCT.md)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
logaretmcommented, Jul 3, 2022

It looks like a Nuxt caveat since there isn’t a way to force vee-validate and nuxt to use the same Vue instance.

A current workaround recommended by them is to add build.transpile with an array of libraries that import Vue themselves.

import { defineNuxtConfig } from 'nuxt'

// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
  build: {
    transpile: ['vee-validate']
  }
})

I tried running the server locally and warnings are gone once I added vee-valdiate to build.transpile. Can you try that and let me know?

Closing this for now, LMK if that doesn’t work for you and I will re-open and check.

0reactions
productdevbookcommented, Sep 12, 2022

@productdevbook Can you provide a sample of this? Doesn’t the proposed solution work?

I think monorepo problem. @logaretm

https://github.com/huntersofbook/huntersofbook/blob/78bc2b1bae60e711aa74c04da6eaf01f0617209d/apps/playground/vite.config.ts#L16-L18

add and fixid.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A error in Nuxt3 · Discussion #5427 · nuxt/framework - GitHub
I was trying out nuxt3-rc3 and three.js, but suddenly I faced this error: ... [Vue warn]: inject() can only be used inside setup()...
Read more >
Vue 3 - inject() can only be used inside setup or functional ...
My app makes an await api call to the backend and if there is an error calls my composition function. [Vue warn]: inject()...
Read more >
Vue 3 - inject() can only be used inside setup() or functional ...
My app makes an await api call to the backend and if there is an error calls my composition function. [Vue warn]: inject()...
Read more >
Installation - Nuxt
Creating a Nuxt project from scratch only requires one file and one directory. We will use the terminal to create the directories and...
Read more >
Introduction to Nuxt 3 modules - DEV Community ‍ ‍
In this article, we will be taking a look at @nuxtjs/strapi module as it is Nuxt 3 compatible, very well developed and documented....
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found