Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nuxt] [request error] [unhandled] [500] Cannot access 'nitroApp' before initialization #65

Open
fdfrontdev opened this issue Jul 9, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@fdfrontdev
Copy link

fdfrontdev commented Jul 9, 2024

Version

"nuxt": "^3.11.2",
"nuxt-cron": "^1.5.1",

Describe the problem

When using the command npm run dev, expect the nuxt server to run, instead got error

steps to reproduce:

  1. npm install nuxt-cron -D
  2. file : nuxt.config.ts
export default defineNuxtConfig({
  modules: ['nuxt-cron'],
cron: {
    runOnInit: true,
    timeZone: 'Asia/Kuala_Lumpur',
    jobsDir: 'cron'
  }
})

4.file : server/cron/job.ts

import { defineCronHandler } from '#nuxt/cron'

export default defineCronHandler('0 8 * * *', () => {
  try {
    console.log('I run every 8 am')
  } catch (error) {
    throw createError({
      statusCode: 404,
      statusMessage: 'Fail to run scheduler'
    })
  }
})

  1. npm run dev
  2. expected result: nuxt server running
  3. actual result : [nuxt] [request error] [unhandled] [500] Cannot access 'nitroApp' before initialization

Additional info

image

@fdfrontdev fdfrontdev added the bug Something isn't working label Jul 9, 2024
@hywax-assistant
Copy link
Collaborator

👋 @fdfrontdev
Thanks for opening your first issue here!
To help make it easier for us to investigate your issue, please follow the contributing guidelines.

If you like this project, please ⭐ star our repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants