Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Using SQL ORMs with Node.js Defining Models Go Further with Models

jcruzaxaeon
seal-mask
.a{fill-rule:evenodd;}techdegree
jcruzaxaeon
Full Stack JavaScript Techdegree Student 16,520 Points

Date Format Deprecation Warning

ORMs Instruction Page (using Sequelize, SQLite, Node.js)

Going Further with Models

https://teamtreehouse.com/library/using-sql-orms-with-nodejs/go-further-with-models#questions

Issue

The instruction-page uses '2024-01-22' as the value when creating a Movie-entry which results in deprecation warning below.

Deprecation Warning

Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.
Arguments:
[0] _isAMomentObject: true, _isUTC: false, _useUTC: false, _l: undefined, _i: false, _f: undefined, _strict: undefined, _locale: [object Object]
Error
    at Function.createFromInputFallback (/mnt/c/core/home/jcruz/dev/tth/ws/8512/node_modules/moment/moment.js:324:25)
    at configFromInput (/mnt/c/core/home/jcruz/dev/tth/ws/8512/node_modules/moment/moment.js:3068:19)
    at prepareConfig (/mnt/c/core/home/jcruz/dev/tth/ws/8512/node_modules/moment/moment.js:3039:13)
    at createFromConfig (/mnt/c/core/home/jcruz/dev/tth/ws/8512/node_modules/moment/moment.js:3006:44)
    at createLocalOrUTC (/mnt/c/core/home/jcruz/dev/tth/ws/8512/node_modules/moment/moment.js:3100:16)
    at createLocal (/mnt/c/core/home/jcruz/dev/tth/ws/8512/node_modules/moment/moment.js:3104:16)
    at hooks (/mnt/c/core/home/jcruz/dev/tth/ws/8512/node_modules/moment/moment.js:16:29)
    at DATEONLY._stringify (/mnt/c/core/home/jcruz/dev/tth/ws/8512/node_modules/sequelize/lib/data-types.js:352:12)
    at DATEONLY.stringify (/mnt/c/core/home/jcruz/dev/tth/ws/8512/node_modules/sequelize/lib/data-types.js:22:19)
    at SQLiteQueryGenerator.escape (/mnt/c/core/home/jcruz/dev/tth/ws/8512/node_modules/sequelize/lib/dialects/abstract/query-generator.js:756:30)

What do I need to do to get rid of this warning?

1 Answer

jcruzaxaeon
seal-mask
.a{fill-rule:evenodd;}techdegree
jcruzaxaeon
Full Stack JavaScript Techdegree Student 16,520 Points

If you feel comfortable modifying an imported package you can fix the "Deprecation Error" as follows:

  1. Open node_modules\moment\moment.js
  2. Search for function configFromInput(config) declaration (line 3049 as of this note)
  3. Add the following check just before the final "fallback" else {...}:
   // Additional else if: if `config._i==false`, do nothing
   else if (!config._i) { return; }

This fixed the "Deprecation Error" for me, but is likely not the ideal solution.