search

Home  >  Q&A  >  body text

Does anyone know how to install @nuxtjs/composition-api in nuxt3?

<p>I had a Nuxt 2 project before, in which the version of the "@nuxtjs/composition-api" package installed was "^0.33.1". Now I need to change Nuxt version from 2.5 to 3.6.2. If you can help me solve this problem, I will be very grateful. </p><p>I have made the changes but am currently getting an error when running the yarn dev command. </p><p><br /></p> <pre class="brush:php;toolbar:false;">ERROR error while updating dependencies: 4:36:09 PM Error: Build failed with 3 errors: node_modules/@nuxtjs/composition-api/dist/runtime/index.mjs:1:175: ERROR: No matching export in "node_modules/vue/dist/vue.runtime.esm-bundler.js" for import "set" node_modules/@nuxtjs/composition-api/dist/runtime/index.mjs:2:30: ERROR: No matching export in "node_modules/vue/dist/vue.runtime.esm-bundler.js" for import "del" node_modules/@nuxtjs/composition-api/dist/runtime/index.mjs:2:409: ERROR: No matching export in "node_modules/vue/dist/vue.runtime.esm-bundler.js" for import "set" at failureErrorWithLog (C:UsersskyWebtestfrontendnode_modulesvitenode_modulesesbuildlibmain.js:1636:15) at C:UsersskyWebtestfrontendnode_modulesvitenode_modulesesbuildlibmain.js:1048:25 at C:UsersskyWebtestfrontendnode_modulesvitenode_modulesesbuildlibmain.js:1512:9 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)</pre> <p>Where can I find the documentation (((, if I remove this package, I get an error when importing import {onMounted, computed, useRoute, useContext, ref} from "@nuxtjs/composition-api" .</p>
P粉195200437P粉195200437511 days ago581

reply all(1)I'll reply

  • P粉194919082

    P粉1949190822023-07-29 11:24:51

    @nuxtjs/composition-api package brings Composition API functionality back to Vue2, however this is no longer needed because Nuxt3 is built on Vue3. To resolve this issue, you should remove the package from package.json and dependencies, and can directly use the relevant Composition API functions (ref, computed, etc.) without any imports, as Nuxt now handles this via automatic imports. You can learn more at the following link:

    https://nuxt.com/docs/guide/concepts/auto-imports

    Hope this helps you migrate to Nuxt 3 :)


    reply
    0
  • Cancelreply