时刻弃用警告:不建议使用日期访问器。使用日期代替

时间:2018-07-31 09:00:44

标签: node.js momentjs

Moment.js弃用警告

错误信息:

Deprecation warning: dates accessor is deprecated. Use date instead.
Arguments: 
Error
    at Moment.dates (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/moment/moment.js:320:98)
    at eval (eval at compile (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/ejs/lib/ejs.js:549:12), <anonymous>:61:39)
    at returnedFn (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/ejs/lib/ejs.js:580:17)
    at tryHandleCache (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/ejs/lib/ejs.js:223:34)
    at View.exports.renderFile [as engine] (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/ejs/lib/ejs.js:437:10)
    at View.render (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/express/lib/view.js:135:8)
    at tryRender (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/express/lib/application.js:640:10)
    at Function.render (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/express/lib/application.js:592:3)
    at ServerResponse.render (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/express/lib/response.js:1008:7)
    at /Users/ephraimguo/Documents/OST_work/booking_Prototype/routes/index.js:248:18
    at Layer.handle [as handle_request] (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/express/lib/router/layer.js:95:5)
    at /Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/Users/ephraimguo/Documents/OST_work/booking_Prototype/node_modules/express/lib/router/index.js:335:12)

尝试使用矩对象替换Date()对象,但仍然存在相同的错误。 我想知道如何解决此错误,尽管它不会影响性能,但是如果出现任何错误,则无法实施群集。

1 个答案:

答案 0 :(得分:0)

从Moment 2.6.0版开始,不推荐使用dates(), years(),从2.10.0版开始不推荐使用months()。因此,建议使用date(), month(), year()

要删除弃用警告,see my answer here

相关问题