hexo博客next主题引入wordcount后,执行hexo命令报错?

查看:547
本文介绍了hexo博客next主题引入wordcount后,执行hexo命令报错?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

我想为我的博客(hexo博客,next主题)添加字数统计功能,按照网上的办法,先执行了下面的代码:

$ npm install hexo-wordcount --save

执行完成后提示成功,然后修改主题配置文件

post_wordcount:
  item_text: true
  wordcount: true
  min2read: true

修改完成后,执行 hexo clean、hexo g、hexo d这些命令,每个都报错,但是报错之后这些命令也能正确执行。
下面是执行hexo clean后的报错信息:

ERROR Plugin load failed: hexo-wordcount
SyntaxError: Unexpected token {
    at Object.exports.runInThisContext (vm.js:53:16)
    at D:\Github\hexo\node_modules\_hexo@3.3.6@hexo\lib\hexo\index.js:230:17
    at tryCatcher (D:\Github\hexo\node_modules\_bluebird@3.5.0@bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (D:\Github\hexo\node_modules\_bluebird@3.5.0@bluebird\js\release\promise.js:512:31)
    at Promise._settlePromise (D:\Github\hexo\node_modules\_bluebird@3.5.0@bluebird\js\release\promise.js:569:18)
    at Promise._settlePromise0 (D:\Github\hexo\node_modules\_bluebird@3.5.0@bluebird\js\release\promise.js:614:10)
    at Promise._settlePromises (D:\Github\hexo\node_modules\_bluebird@3.5.0@bluebird\js\release\promise.js:693:18)
    at Promise._fulfill (D:\Github\hexo\node_modules\_bluebird@3.5.0@bluebird\js\release\promise.js:638:18)
    at Promise._resolveCallback (D:\Github\hexo\node_modules\_bluebird@3.5.0@bluebird\js\release\promise.js:432:57)
    at Promise._settlePromiseFromHandler (D:\Github\hexo\node_modules\_bluebird@3.5.0@bluebird\js\release\promise.js:524:17)
    at Promise._settlePromise (D:\Github\hexo\node_modules\_bluebird@3.5.0@bluebird\js\release\promise.js:569:18)
    at Promise._settlePromise0 (D:\Github\hexo\node_modules\_bluebird@3.5.0@bluebird\js\release\promise.js:614:10)
    at Promise._settlePromises (D:\Github\hexo\node_modules\_bluebird@3.5.0@bluebird\js\release\promise.js:693:18)
    at Promise._fulfill (D:\Github\hexo\node_modules\_bluebird@3.5.0@bluebird\js\release\promise.js:638:18)
    at D:\Github\hexo\node_modules\_bluebird@3.5.0@bluebird\js\release\nodeback.js:42:21
    at D:\Github\hexo\node_modules\_graceful-fs@4.1.11@graceful-fs\graceful-fs.js:78:16
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
INFO  Deleted database.

请问这个错误是怎么回事?现在字数统计功能也没实现,不知道怎么弄了,求助!!!

解决方案

基本上是你文件有地方写法错误,而不是这个插件的问题

可能的原因:

文章中使用了now( ), 小括号( )属于特殊字符,在编译文章时将now( )当函数处理了,结果找不到函数,就报错了

文章中使用了大括号 { } 这个特殊字符,且没有转义导致编译不通过

文章中使用了某个特殊字符, 解析时讲表达式中的内容按函数处理了,特殊字符没有转义导致编译不通过

Hexo博客Next主题集成第三方服务Hexo博客Next主题配置参考网站

这篇关于hexo博客next主题引入wordcount后,执行hexo命令报错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆