An error occurs. Please tell me how to fix?

Uncaught TypeError: Cannot read property 'replace' of undefined Quote

Module: /node_modules/cron/lib/cron.js

Error line code:

source = this.source.replace (/ [az] {1,3} / ig, function (alias) {

Function code:

_parse: function() { var aliases = CronTime.aliases, source = this.source.replace(/[az]{1,3}/ig, function(alias) { alias = alias.toLowerCase(); if (alias in aliases) { return aliases[alias]; } throw new Error('Unknown alias: ' + alias); }), split = source.replace(/^\s\s*|\s\s*$/g, '').split(/\s+/), cur, i = 0, len = timeUnits.length; for (; i < timeUnits.length; i++) { // If the split source string doesn't contain all digits, // assume defaults for first n missing digits. // This adds support for 5-digit standard cron syntax cur = split[i - (len - split.length)] || CronTime.parseDefaults[i]; this._parseField(cur, timeUnits[i], CronTime.constraints[i]); } } 

  • Make console.log(this.source); in front of the line with an error console.log(this.source); and see what is contained there. I think there should be a string so that there is no error. - Visman
  • and where in your object you initialize the source field? - torokhkun
  • What is this module and how is it used? - Grundy
  • In 99.99% of cases, the problem is not in a third-party module, but in how you use it. Therefore, instead of the code of another module, add the code using it to the question. - Dmitriy Simushev

0