NuxtN
Nuxt10mo ago
13 replies
Lin

Setting up auto-imports for @nuxt/ui composables throws "Cannot resolve #imports" error

Environment


nuxt:
3.16.2

@nuxt/ui:
3.0.2


Description


I am trying to setup auto-imports for the
useToast
composable following the nuxt doc:

This is settings I have in
nuxt.config.ts
:

{
  imports: {
    scan: false,
    presets: [
      { from: '@nuxt/ui/composables/useToast.js', imports: ['useToast'] },
    ],
  }
}


And I got following error:

X [ERROR] Could not resolve "#imports"

    node_modules/@nuxt/ui/dist/runtime/composables/useToast.js:2:25:
      2 │ import { useState } from "#imports";
        ╵                          ~~~~~~~~~~

  The package import "#imports" is not defined in this "imports" map:

    node_modules/@nuxt/ui/package.json:45:13:
      45 │   "imports": {
         ╵              ^

  You can mark the path "#imports" as external to exclude it from the bundle, which will remove this
  error and leave the unresolved path in the bundle.


 ERROR  error while updating dependencies:                                                                                                                                        8:37:30 AM  
Error: Build failed with 1 error:
node_modules/@nuxt/ui/dist/runtime/composables/useToast.js:2:25: ERROR: Could not resolve "#imports"


Thanks in advance for any help.
Nuxt
Nuxt auto-imports components, composables, helper functions and Vue APIs.
Auto-imports · Nuxt Concepts
Was this page helpful?