N
Nuxt3w ago
ok3n

Cannot start nuxt 3.14.0: Nuxt module should be a function

After updating from 3.13.1 to 3.14.0, we are getting the following error: Cannot start nuxt: Nuxt module should be a function: @custom-vite-alias/module Our nuxt config:
modules: [
'@custom-vite-alias/module',
],
alias: {
'@custom-vite-alias': path.resolve(__dirname, './../../shared/utils/'),
}
modules: [
'@custom-vite-alias/module',
],
alias: {
'@custom-vite-alias': path.resolve(__dirname, './../../shared/utils/'),
}
and our custom module in ./../../.shared/utils/module/index.js (taken from the official documentation)
import { defineNuxtModule } from '@nuxt/kit'

export default defineNuxtModule((options, nuxt) => {
nuxt.hook('pages:extend', pages => {
console.log(`Discovered ${pages.length} pages`)
})
})
import { defineNuxtModule } from '@nuxt/kit'

export default defineNuxtModule((options, nuxt) => {
nuxt.hook('pages:extend', pages => {
console.log(`Discovered ${pages.length} pages`)
})
})
Any ideas on how to fix it?
3 Replies
kapa.ai
kapa.ai3w ago
Hi @ok3n. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in your question and the knowledge sources available, I can offer some insights and suggestions to help resolve your issue with Nuxt 3.14.0. The error message you're receiving suggests that Nuxt is expecting a function for the module, but it's not finding one. This could be due to a few reasons: 1. Module Export: Make sure your module is exporting the function correctly. The example you provided looks correct, as it uses defineNuxtModule from @nuxt/kit, which is the recommended way to create Nuxt modules as shown in the documentation (https://nuxt.com/docs/api/kit/modules#examples). 2. Module Path: Ensure that the path to your module is correct. In your nuxt.config.ts, you're using '@custom-vite-alias/module', but the actual path you mentioned is ./../../shared/utils/module/index.js. Make sure these align correctly. 3. Alias Configuration: Your alias configuration looks like it's trying to point @custom-vite-alias to a directory, but your module is being referenced as @custom-vite-alias/module. Make sure the alias is set up correctly to include the module file. Here's a suggestion to modify your nuxt.config.ts:
import { defineNuxtConfig } from 'nuxt/config'
import path from 'path'

export default defineNuxtConfig({
modules: [
path.resolve(__dirname, './../../shared/utils/module')
],
alias: {
'@custom-vite-alias': path.resolve(__dirname, './../../shared/utils/')
}
})
import { defineNuxtConfig } from 'nuxt/config'
import path from 'path'

export default defineNuxtConfig({
modules: [
path.resolve(__dirname, './../../shared/utils/module')
],
alias: {
'@custom-vite-alias': path.resolve(__dirname, './../../shared/utils/')
}
})
This change directly references the module file path instead of using the alias in the modules array. If this doesn't resolve the issue, you might want to check: 1. That the @nuxt/kit package is correctly installed and up to date. 2. That there are no syntax errors in your module file. 3. That the module file is being transpiled correctly if you're using TypeScript. If the problem persists, you may want to try creating a minimal reproduction of the issue and reporting it to the Nuxt GitHub repository (https://github.com/nuxt/nuxt/issues), as this could potentially be a bug introduced in version 3.14.0. Remember, when upgrading Nuxt, it's always a good idea to check the upgrade guide (https://nuxt.com/docs/getting-started/upgrade) for any breaking changes or new requirements that might affect your project. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3w ago
<@407208375349280778> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
ok3n
ok3nOP3w ago
Tried all of that already, wouldn't have opened a discord ticket if I wasn't on my last leg 😄
Want results from more Discord servers?
Add your server