hexo-starter
hexo-starter copied to clipboard
hello-world.md lacks a date
err: Error: `NaN` is not a valid date!
Initializing a new blog and running the server results in an error because hello-world.md lacks a date.
Adding a date to source/_posts/hello-world.md resolves the issue.
hexo: 5.4.0
hexo-cli: 4.3.0
os: freebsd 12.2-RELEASE-p2
node: 14.17.6
v8: 8.4.371.23-node.76
uv: 1.41.0
zlib: 1.2.11
brotli: 1.0.9
ares: 1.17.1
modules: 83
nghttp2: 1.43.0
napi: 8
llhttp: 2.1.3
openssl: 1.1.1l
cldr: 39.0
icu: 69.1
tz: 2021a
unicode: 13.0
I can't reproduce this issue, could you provide the complete call stack of the error?
Can't reproduce either. In fact, our unit test includes generating a dummy blog site with 500 posts (all without date). So I doubt if it is really related with Hexo.
Freebsd might have something to do with the error?
What's the normal behavior? Is it meant to pull a date from the file system if there is none found in the front matter? It's reasonable to think that could have an OS-specific issue.
Posts created with hexo new
have a date in the front matter and don't cause an issue.
Here is the full trace.
/h/p/hxblog> npx hexo list post
INFO Validating config
INFO Start processing
ERROR {
err: Error: `NaN` is not a valid date!
at SchemaTypeMoment.validate (/home/protected/hxblog/node_modules/hexo/lib/models/types/moment.js:31:13)
at Array.<anonymous> (/home/protected/hxblog/node_modules/warehouse/lib/schema.js:510:27)
at Schema._applySetters (/home/protected/hxblog/node_modules/warehouse/lib/schema.js:640:15)
at _Model._insertOne (/home/protected/hxblog/node_modules/warehouse/lib/model.js:158:12)
at /home/protected/hxblog/node_modules/warehouse/lib/model.js:179:63
at tryCatcher (/home/protected/hxblog/node_modules/bluebird/js/release/util.js:16:23)
at /home/protected/hxblog/node_modules/bluebird/js/release/using.js:185:26
at tryCatcher (/home/protected/hxblog/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/protected/hxblog/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/home/protected/hxblog/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/home/protected/hxblog/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/home/protected/hxblog/node_modules/bluebird/js/release/promise.js:729:18)
at Promise._fulfill (/home/protected/hxblog/node_modules/bluebird/js/release/promise.js:673:18)
at PromiseArray._resolve (/home/protected/hxblog/node_modules/bluebird/js/release/promise_array.js:127:19)
at PromiseArray._promiseFulfilled (/home/protected/hxblog/node_modules/bluebird/js/release/promise_array.js:145:14)
at Promise._settlePromise (/home/protected/hxblog/node_modules/bluebird/js/release/promise.js:609:26)
} Process failed: %s _posts/hello-world.md
/h/p/hxblog> npx hexo server -i 127.0.0.1
INFO Validating config
INFO Start processing
ERROR {
err: Error: `NaN` is not a valid date!
at SchemaTypeMoment.validate (/home/protected/hxblog/node_modules/hexo/lib/models/types/moment.js:31:13)
at Array.<anonymous> (/home/protected/hxblog/node_modules/warehouse/lib/schema.js:510:27)
at Schema._applySetters (/home/protected/hxblog/node_modules/warehouse/lib/schema.js:640:15)
at _Model._insertOne (/home/protected/hxblog/node_modules/warehouse/lib/model.js:158:12)
at /home/protected/hxblog/node_modules/warehouse/lib/model.js:179:63
at tryCatcher (/home/protected/hxblog/node_modules/bluebird/js/release/util.js:16:23)
at /home/protected/hxblog/node_modules/bluebird/js/release/using.js:185:26
at tryCatcher (/home/protected/hxblog/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/protected/hxblog/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/home/protected/hxblog/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/home/protected/hxblog/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/home/protected/hxblog/node_modules/bluebird/js/release/promise.js:729:18)
at Promise._fulfill (/home/protected/hxblog/node_modules/bluebird/js/release/promise.js:673:18)
at PromiseArray._resolve (/home/protected/hxblog/node_modules/bluebird/js/release/promise_array.js:127:19)
at PromiseArray._promiseFulfilled (/home/protected/hxblog/node_modules/bluebird/js/release/promise_array.js:145:14)
at Promise._settlePromise (/home/protected/hxblog/node_modules/bluebird/js/release/promise.js:609:26)
} Process failed: %s _posts/hello-world.md
However, it is commemorative to record the date of the hello world article (it is also the creation time of the blog site).
Maybe we can design a special hexo new
command to run automatically after hexo init
, to solve this issue
When no date is specified in front-matter, hexo uses the file date. If it fails, I'd guess it's probably related to file system and permissions. Please try to delete the file and rebuild it, or use another volume.