NuxtN
Nuxt3y ago
6 replies
Fabian B.

Create local Nuxt modules inside a Nuxt project: Do I need a build step?

Hey there! Question to all that worked with modules, especially local ones:
I want to create some modules that will live only locally inside my nuxt project. I have done that by creating a modules/my-module/module.ts and modules/my-module/runtime/plugin.ts like you would get from the module starter template. I am using the module in my main app like:

export default defineNuxtConfig({
  modules: ['./modules/my-module/module.ts']
})


This works so far.

My question:

Now I want to install some dependencies and also inject some types from this module into my main app. Normally you would have "prepack": "nuxt-module-build", in your package.json which would generate some dist/...mjs files. Is this needed when my module is locally installed directly inside a nuxt app? Or can I get types and dependencies to work without that.
Was this page helpful?