Croner is a zero-dependency JavaScript library designed for scheduling and executing functions based on cron expressions across all JavaScript environments, including Node.js (v18.0+) and modern browsers. The current stable version is 10.0.1, with a consistent release cadence for bug fixes and minor enhancements, as indicated by recent development builds. A major differentiator is its full compliance with OCPS 1.4, offering advanced scheduling capabilities like an optional seventh field for year specification and robust handling of complex cron patterns. Version 10 introduced features such as the `match()` method for pattern validation, `dayOffset` for relative scheduling, and improved DST fall-back behavior. It stands out for its isomorphic design and comprehensive feature set without external dependencies, providing a reliable and lightweight solution for various task scheduling needs.
npm install cronerVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to create recurring and one-time cron jobs, retrieve next execution times, and stop a running job.
Review your cron patterns and configuration options against the Croner v10 documentation. Consider enabling `sloppyRanges` if you rely on more permissive parsing from older versions.
Consult the Croner documentation regarding DST overlap behavior and test your cron patterns thoroughly around known DST transition dates, especially for mission-critical jobs.
Immediately upgrade to `croner@10.0.1` or a later version if you are on 10.0.0 and encountering TypeScript-related issues.
For one-time jobs, set `allowPast: true` in the Cron options if there's a possibility of the scheduled time having just passed at creation: `new Cron(date, callback, { allowPast: true });`Ensure that any errors thrown within the `catch` callback itself are properly handled to prevent the job from unexpectedly stopping. Upgrade to the latest version to benefit from fixes in this area.
Use ESM named import: `import { Cron } from 'croner';`. Ensure your project is configured for ESM if targeting modern Node.js environments (e.g., `"type": "module"` in `package.json`).Upgrade to `croner@10.0.1` or later. Ensure your `tsconfig.json` targets a sufficiently modern JavaScript version and module system.
Verify your cron pattern against OCPS 1.4 specifications. Pay attention to valid ranges, characters, and field counts (up to 7 fields including year). If you need more permissive parsing for legacy patterns, consider adding `{ sloppyRanges: true }` to your Cron options.Specify the `timezone` option explicitly (e.g., `{ timezone: 'America/New_York' }`). Review DST behavior changes in v10.0.2-dev.0. For 'once' jobs, ensure `allowPast: true` is set if the job might be initialized after its nominal start time.No dependency data recorded yet.