Unable to develop an npm linked module (error: "fails to load url")

Hello. I've just set up a starter module repo using the starter template code and have NPM linked it from a Nuxt project. However, when I configure Nuxt to see the module, and start the server, I get the following error:
ERROR Failed to load url /@fs/Volumes/Data/Work/Projects/nuxt-landkit/dist/runtime/plugin.mjs
(resolved id: /Volumes/Data/Work/Projects/nuxt-landkit/dist/runtime/plugin.mjs)
in virtual:nuxt:/Volumes/Data/Work/Projects/controlspace-site/.nuxt/plugins/client.mjs.

Does the file exist?
ERROR Failed to load url /@fs/Volumes/Data/Work/Projects/nuxt-landkit/dist/runtime/plugin.mjs
(resolved id: /Volumes/Data/Work/Projects/nuxt-landkit/dist/runtime/plugin.mjs)
in virtual:nuxt:/Volumes/Data/Work/Projects/controlspace-site/.nuxt/plugins/client.mjs.

Does the file exist?
I have run the prepare and build scripts in the module repo, and I can see the files exist. However, if I copy/paste the code to my app's modules folder, it works first time. Is it that Nuxt / Nitro doesn't see them, or is there something else at play?
4 Replies
harlan
harlan2y ago
Hmm apparently there are some edge case issues with npm link, the recommended solution on the module author guide is to use npm pack https://nuxt.com/docs/guide/going-further/modules#manual-qa-with-playground-and-externally
Nuxt
Module Author Guide · Nuxt Advanced
Learn how to create a Nuxt Module to integrate, enhance or extend any Nuxt applications.
harlan
harlan2y ago
if it's just for testing you can probably do something like
import MyModule from '../../packages/my-module/src/module'

export default defineNuxtConfig({
modules: [
MyModule,
]
})
import MyModule from '../../packages/my-module/src/module'

export default defineNuxtConfig({
modules: [
MyModule,
]
})
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
davestewart
davestewartOP2y ago
Thanks! Will try later
Want results from more Discord servers?
Add your server