Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

194
Views
Not able register hapi-cron-job plugin

I am trying to schedule cronjobs which will run at specified time, i am using hapi-cron-job of hapi, when i try to register the plugin, i am getting below error.

[1] "plugin.register" must be of type function
    at Object.exports.apply (D:\my_dir\Repositories\repo-cronjobs\node_modules\@hapi\hapi\lib\config.js:19:15)
    at internals.Server.register (D:\my_dir\Repositories\repo-cronjobs\node_modules\@hapi\hapi\lib\server.js:454:31)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

Please find the configuration while registering the plugin.

server.js

  const { plugins } = require('./register/index');

  await server
    .register(plugins)
    .then(() => {})
    .catch(err => {
      console.error('Plugin registeration failed!');
      console.error(err);
    });

index.js

module.exports.plugins = [
  // I have here other pluguns, passing this array for registration in server.js 
  require("./hapi-cron-job-plugin")
];

hapi-cron-job-plugin.js

const hapiCronJob = require('hapi-cron-job')
const plugin = {
  register: require('hapi-cron-job'),
  options: {
    jobs: [
      {
        name: "diplay time",
        enabled: true,
        immediate: true,
        schedule: "every 1 s",
        execute: alertSystemAdminAndDispatcher,
        environments: ['development', 'staging']
      }
    ],
  }
}

module.exports = plugin;

nodeJS version: v14.17.3

Hapi-cron-job: "hapi-cron-job": "^2.0.1"

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!