Nitro defineTask in a module
How to register a task in a nuxt module?
Within the project, it registered automatically, but in a module.ts, I can set the cron module, but probably I should call something to actually register it.
I see int he console: WARN Scheduled task notifications:process-queue is not defined!
3 Replies
Hi @BenG. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
I'm sorry, but the provided knowledge sources do not contain information about registering Nitro tasks (such as with defineTask or scheduled/cron tasks) within a Nuxt module. The documentation covers how to add server handlers, plugins, imports, and scan directories in modules, but does not mention Nitro's task system or how to programmatically register tasks from a module context.
If you are using a community module (like @nuxtjs/cron or similar), you may need to consult that module's documentation for the correct way to register tasks from within a module. If you are referring to Nitro's own task system, the official Nuxt and Nitro docs provided here do not cover this feature.
If you have more specific documentation or code examples related to Nitro tasks, please provide them, and I can help further. Otherwise, I recommend checking the latest Nitro or Nuxt documentation or opening an issue in their repositories for guidance.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
<@371347799255547916> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Using the addServerScanDir(resolver.resolve('./runtime/server')) solves the problem both the api endpoint registered automatically and the tasks folder too.