vuejs3nuxt3.js

Nuxt 3 Composables Not Defined


Functions in files in the composables directory are not being auto-imported and are undefined.

I am on Windows, using VS Code.

I have explicitly enabled imports in the nuxt.config.ts:

imports: {
    autoImport: true,
  },

I have tried explicitly / manually importing the composable from #imports

import { useGeolocation } from "#imports";

However, it is clear that the relevant composable is not present in .nuxt imports directory.

I have deleted the .nuxt directory and node-modules and reinstalled / rebuilt.

I have copied the official Nuxt 3 composables example here, but that also does not work.

I have checked the read/write privileges of the project directory and its subdirectories.

Components are auto-importing from the components directory.


Solution

  • In case anyone else is encountering the same problem with auto-importing in Nuxt - I discovered that the problem was related to Dropbox.

    My project was contained within a Dropbox folder and the Dropbox sync process somehow breaks Nuxt.

    I'd be interested in a workaround - in the meantime I have moved my project to the C drive