{"record":{"id":"b546f9ba3284f717","repo":"dianping/cat","slug":"momentjs-is-required","errorCode":null,"errorMessage":"momentjs is required","messagePattern":"momentjs is required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"cat-home/src/main/webapp/assets/js/uncompressed/date-time/bootstrap-datetimepicker.js","lineNumber":48,"sourceCode":"    if (typeof define === 'function' && define.amd) {\n        // AMD is used - Register as an anonymous module.\n        define(['jquery', 'moment'], factory);\n    } else {\n        // AMD is not used - Attempt to fetch dependencies from scope.\n        if (!jQuery) {\n            throw 'bootstrap-datetimepicker requires jQuery to be loaded first';\n        } else if (!moment) {\n            throw 'bootstrap-datetimepicker requires moment.js to be loaded first';\n        } else {\n            factory(jQuery, moment);\n        }\n    }\n}\n\n(function ($, moment) {\n    if (typeof moment === 'undefined') {\n        alert(\"momentjs is requried\");\n        throw new Error('momentjs is required');\n    };\n\n    var dpgId = 0,\n\n    pMoment = moment,\n\n// ReSharper disable once InconsistentNaming\n    DateTimePicker = function (element, options) {\n        var defaults = {\n            pickDate: true,\n            pickTime: true,\n            useMinutes: true,\n            useSeconds: false,\n            useCurrent: true,\n            minuteStepping: 1,\n            minDate: new pMoment({ y: 1900 }),\n            maxDate: new pMoment().add(100, \"y\"),\n            showToday: true,","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/dianping/cat/blob/e815e74d4c2dd74edac831241f1253fcc7d25381/cat-home/src/main/webapp/assets/js/uncompressed/date-time/bootstrap-datetimepicker.js#L30-L66","documentation":"This datetimepicker plugin (the Smalot/bootstrap-datetimepicker style factory wrapper here paired with an older picker) requires moment.js to be present. After the UMD factory check, the main IIFE re-checks typeof moment === 'undefined' and both alerts and throws. Without moment the picker cannot parse/format dates, so it refuses to initialize.","triggerScenarios":"Loading bootstrap-datetimepicker.js before moment.js; moment.js 404ing; a page where only the datepicker (not datetimepicker) is needed but this script is still included; using a bundler that does not resolve moment as an external.","commonSituations":"Template includes moment.js only on some pages while the datetimepicker script is included globally; aggressive concatenation reordering files alphabetically (bootstrap-datetimepicker before moment); CDN failure for moment.","solutions":["Add <script src=\".../moment.min.js\"></script> before bootstrap-datetimepicker.js on every page that uses the picker.","Verify moment loads (Network tab / typeof moment in console).","If you do not need time picking, use the plain bootstrap-datepicker instead, which has no moment dependency."],"exampleFix":"// before\n<script src=\"bootstrap-datetimepicker.js\"></script>\n\n// after\n<script src=\"moment.min.js\"></script>\n<script src=\"bootstrap-datetimepicker.js\"></script>","handlingStrategy":"validation","validationCode":"if (typeof window.moment === 'undefined') {\n  console.error('moment.js missing: bootstrap-datetimepicker will not initialize.');\n} else {\n  $('#dt').datetimepicker();\n}","typeGuard":"function datetimepickerDepsReady() {\n  return typeof window.jQuery === 'function' && typeof window.moment !== 'undefined';\n}","tryCatchPattern":null,"preventionTips":["Include moment.js in the same template fragment as the datetimepicker, on every page using it.","Bundlers: add moment as an explicit dependency so it cannot be tree-shaken or reordered away.","For date-only fields use bootstrap-datepicker, which needs no moment."],"tags":["datetimepicker","momentjs","script-order","dependencies","vendor"],"backgroundTag":null,"analyzedSha":"e815e74d4c2dd74edac831241f1253fcc7d25381","analyzedAt":"2026-08-14T14:22:34.512Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}