#Issue with custom modules

1 messages · Page 1 of 1 (latest)

umbral egret
#

Hi there!

I'm working on an internal UI library for Nuxt. I've adopted similar implementations like the NuxtLab/ui library but I keep getting this error:

ERROR  This module cannot be imported in the Vue part of your app. [importing @nuxt/kit from ../../node_modules/.pnpm/github.com+salfatigroup+ui@13682abd633a924be0c5caa482b3c6f4e1d652cf/node_modules/@salfatigroup/ui/src/module.ts?v=f1bb0ab6]

Here's my module.ts file:

import { defineNuxtModule, addComponentsDir, createResolver, addPlugin } from '@nuxt/kit'
import { name, version } from '../package.json'

export interface ModuleOptions {
  /**
   * @default 'k'
   */
  prefix?: string
}

export default defineNuxtModule<ModuleOptions>({
  meta: {
    name,
    version,
    configKey: 'ui',
    compatibility: {
      nuxt: '^3.0.0'
    }
  },
  defaults: {
    prefix: 'k',
  },
  async setup (options, nuxt) {
    const { resolve } = createResolver(import.meta.url)

    // Transpile runtime
    const runtimeDir = resolve('./runtime')
    nuxt.options.build.transpile.push(runtimeDir)

    addPlugin({
      src: resolve(runtimeDir, 'plugins', 'uid'),
    })

    addComponentsDir({
      path: resolve(runtimeDir, 'components'),
      prefix: options.prefix,
      watch: false
    })
  }
})

Any suggestions?

inner hare
#

Possibly a bug, how are you using the module

umbral egret
#

Just regularly - unless you had something specific in mind you wanted me check?

inner hare
#

How is it linked?

#

It's a published npm package or loading using pnpm link?

umbral egret
#

It's install directly from github - no links or anything like that

hard hollow
#

hi @umbral egret , did you find a solution to this issue? I'm facing the same one. Thanks!